Skip to content

fix(menu): accidentally tapping on sub-menu content that overlaps trigger on touch devices #14538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
18 changes: 11 additions & 7 deletions src/lib/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ $mat-menu-submenu-indicator-size: 10px !default;
border-radius: $mat-menu-border-radius;
outline: 0;

// Prevent users from interacting with the panel while it's animating. Note that
// people won't be able to click through it, because the overlay pane will catch the click.
// This fixes the following issues:
// * Users accidentally opening sub-menus when the `overlapTrigger` option is enabled.
// * Users accidentally tapping on content inside the sub-menu on touch devices, if the
// sub-menu overlaps the trigger. The issue is due to touch devices emulating the
// `mouseenter` event by dispatching it on tap.
&.ng-animating {
pointer-events: none;
}

@include cdk-high-contrast {
outline: solid 1px;
}
Expand Down Expand Up @@ -70,13 +81,6 @@ $mat-menu-submenu-indicator-size: 10px !default;
transform: rotateY(180deg) translateY(-50%);
}
}

// Prevent the user from interacting while the panel is still animating.
// This avoids issues where the user could accidentally open a sub-menu,
// because of the `overlapTrigger` option.
.mat-menu-panel.ng-animating & {
pointer-events: none;
}
}

button.mat-menu-item {
Expand Down