Skip to content

Commit

Permalink
fix(material/menu): animation issue when same menu is used for multip…
Browse files Browse the repository at this point in the history
…le nested triggers

If the same menu is passed to different triggers and the user moves quickly between the menus (e.g. in a nested menu), an empty menu panel can show up while the closed menu is animating away. This is because the content needs to be moved over to the new menu.

These changes hide the empty menu panel immediately using CSS to avoid the glichy behavior.
  • Loading branch information
crisbeto committed Jun 19, 2024
1 parent 738f57c commit 72ea750
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/material/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ mat-menu {
// `mouseenter` event by dispatching it on tap.
&.ng-animating {
pointer-events: none;

// If the same menu is assigned to multiple triggers and the user moves quickly between them
// (e.g. in a nested menu), the panel for the old menu may show up as empty while it's
// animating away. Hide such cases since they can look off to users.
&:has(.mat-mdc-menu-content:empty) {
display: none;
}
}

@include cdk.high-contrast(active, off) {
Expand Down

0 comments on commit 72ea750

Please sign in to comment.