Skip to content

Commit 27defc2

Browse files
committed
tweak
1 parent 1fa6e3b commit 27defc2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/material/menu/menu-trigger.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,13 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
282282
}
283283

284284
/** Opens the menu. */
285-
openMenu(disableAutoFocus?: boolean): void {
285+
openMenu(): void {
286+
// Auto focus by default
287+
this._openMenu(true);
288+
}
289+
290+
/** Internal method to open menu providing option to auto focus on first item. */
291+
private _openMenu(autoFocus: boolean): void {
286292
const menu = this.menu;
287293

288294
if (this._menuOpen || !menu) {
@@ -317,7 +323,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
317323
this._closingActionsSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
318324
menu.parentMenu = this.triggersSubmenu() ? this._parentMaterialMenu : undefined;
319325
menu.direction = this.dir;
320-
if (!disableAutoFocus) menu.focusFirstItem(this._openedBy || 'program');
326+
if (autoFocus) menu.focusFirstItem(this._openedBy || 'program');
321327
this._setIsMenuOpen(true);
322328

323329
if (menu instanceof MatMenu) {
@@ -593,7 +599,7 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
593599
// Open the menu, but do NOT auto-focus on first item when just hovering.
594600
// When VoiceOver is enabled, this is particularly confusing as the focus will
595601
// cause another hover event, and continue opening sub-menus without interaction.
596-
this.openMenu(true);
602+
this._openMenu(false);
597603
}
598604
});
599605
}

0 commit comments

Comments
 (0)