I am triggering a dialog on clicking an item in matMenu but the concern is that matMenu doesn't close when dialog is open. I want it to close it as soon as dialog box opens up, it closes when you click somewhere in the page, but I want it to close once dialog box opens.
this is the code-snippet for matMenu.
<button mat-icon-button [matMenuTriggerFor]="menu" #menuTrigger="matMenuTrigger" (mouseup)="menuTrigger.closeMenu()">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu" xPosition="before" >
<button mat-menu-item (click)="openUpdateQuestionDialog($event,currentSelectedQuestion)">
Edit
</button>
<button mat-menu-item (click)="confirmDeleteQuestion($event,currentSelectedQuestion)">
Delete
</button>
</mat-menu>
I am trying different ways to make it work, but no luck.
1. menu with an id like #menu="matMenu, 2. calling menuTrigger.closeMenu() in the template 3. having @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; 4. explicit calling this.trigger.closeMenu();
Also @bugs answer help in figuring this out. – Dublin