Skip to content

Commit ce195de

Browse files
committed
fix(material/menu): animation issue when same menu is used for multiple nested triggers (#29280)
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. (cherry picked from commit 3550a87)
1 parent 2dff093 commit ce195de

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/material/menu/menu.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ mat-menu {
5656
// `mouseenter` event by dispatching it on tap.
5757
&.ng-animating {
5858
pointer-events: none;
59+
60+
// If the same menu is assigned to multiple triggers and the user moves quickly between them
61+
// (e.g. in a nested menu), the panel for the old menu may show up as empty while it's
62+
// animating away. Hide such cases since they can look off to users.
63+
&:has(.mat-mdc-menu-content:empty) {
64+
display: none;
65+
}
5966
}
6067

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

0 commit comments

Comments
 (0)