Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/lib/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
/** References the menu instance that the trigger is associated with. */
@Input('matMenuTriggerFor') menu: MatMenuPanel;

/** Disables auto-closing the menu when the user clicks inside the panel */
@Input() disableClose: boolean = false;


/** Event emitted when the associated menu is opened. */
@Output() menuOpened = new EventEmitter<void>();

Expand Down Expand Up @@ -186,7 +190,16 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {

/** Toggles the menu between the open and closed states. */
toggleMenu(): void {
return this._menuOpen ? this.closeMenu() : this.openMenu();
if (this.disableClose) {
if (this._menuOpen && !this._element.nativeElement.contains(event.target)) {
this.closeMenu();
} else {
this.openMenu();
}
} else {
this._menuOpen ? this.closeMenu() : this.openMenu();
}
this._menuOpen ? this.closeMenu() : this.openMenu();
}

/** Opens the menu. */
Expand Down