Skip to content

bug(button): mouseleave event fired when button becomes disabled without actually leaving the element #32846

@erengeez

Description

@erengeez

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

If the cursor is on the matButton and the button becomes disabled then the mouseleave event is fired. That does not happen with the native button.

Reproduction

StackBlitz link: https://stackblitz.com/edit/ykrngweg?file=src%2Fexample%2Fbutton-disabled-mouseleave-example.html
Steps to reproduce:

  1. Click on a "Click to disable" elevated material button, keep the cursor on the button
  2. Button becomes disabled
  3. mouseleave event is fired and the event message gets added to the array showing "mouseleave fired on material!" text

Clicking on the native button with the same onclick and onmouseleave logic does not fire the mouseleave event, only when the cursor actually left the button element

Expected Behavior

The material button behaviour should be the same as of the native button - mouseleave should not be triggered if the cursor did not leave the button

Actual Behavior

mouseleave event is fired when the material button becomes disabled even if the cursor is over the button

Environment

  • Angular: 21.1.2
  • CDK/Material: 21.1.2
  • Browser(s): Chrome 145.0.7632.109 (arm64)
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS 15.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions