Skip to content

Commit 85ed655

Browse files
committed
fix(material/menu): prevent child menu reopening while parent is animating away (#31958)
Fixes that it was possible for the user to re-open a child menu if they quickly hover back to the parent meny while it's animating away. Fixes #31956. (cherry picked from commit 81eeff4)
1 parent 9290dc5 commit 85ed655

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/material/menu/menu-trigger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ export class MatMenuTrigger extends MatMenuTriggerBase implements AfterContentIn
211211
// Subscribe to changes in the hovered item in order to toggle the panel.
212212
if (this.triggersSubmenu() && this._parentMaterialMenu) {
213213
this._hoverSubscription = this._parentMaterialMenu._hovered().subscribe(active => {
214-
if (active === this._menuItemInstance && !active.disabled) {
214+
if (
215+
active === this._menuItemInstance &&
216+
!active.disabled &&
217+
// Ignore hover events if the parent menu is in the process of being closed (see #31956).
218+
this._parentMaterialMenu?._panelAnimationState !== 'void'
219+
) {
215220
this._openedBy = 'mouse';
216221
// Open the menu, but do NOT auto-focus on first item when just hovering.
217222
// When VoiceOver is enabled, this is particularly confusing as the focus will

0 commit comments

Comments
 (0)