Feature Request
Click events should not propagate with matMenuTriggerFor.
Click events do propagate when a matMenuTriggerFor is invoked.
<a (click)="dontOpenMeWhenAMenuIsClicked()"> .... <button matMenuTriggerFor="...."></button> </a>
And yes this is surely not perfect HTML but there are use cases, like for example when you have table row that expands on click but the UX designer wants a menu button in there as well.
When clicking to open a menu that's the only desired behavior.
all
I feel like doing it for all menu triggers is way too opinionated and it could break existing users. Closing since it's trivial to workaround on the consuming side.
FWIW this should do the trick
<button (click)="$event.stopPropagation()" mat-button [matMenuTriggerFor]="menu">Menu</button>
@crisbeto I have similar functionality but I am not sure if I experience the same error.
In my case I have a image that I want to view or edit so I open a menu with 2 options clicking on the image
Whenever I use the mouse it works well but when I add (keydown) ="...'" to use the keyboard - I get a new mose event from somewhere ? So even using event.stopPropagation() inside openMenuKeyboard(...) doesn't help.
Simplified version of the case is here: https://stackblitz.com/edit/angular-jov1k4
Do you think should I fill a new issue or is the same?
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
FWIW this should do the trick