Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-menu/menu.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('menu', () => {

it('should run not run click handlers on disabled menu items', async () => {
await page.trigger().click();
await page.items(2).click();
await browser.actions().mouseMove(page.items(2)).click();
expect(await page.getResultText()).toEqual('');
});

Expand Down
6 changes: 6 additions & 0 deletions src/material-experimental/mdc-menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
text-decoration: none;

&[disabled] {
// Usually every click inside the menu closes it, however some browsers will stop events
// when the user clicks on a disabled item, **except** when the user clicks on a non-disabled
// child node of the disabled button. This is inconsistent because some regions of a disabled
// button will still cause the menu to close and some won't (see #16694). We make the behavior
// more consistent by disabling pointer events and allowing the user to click through.
pointer-events: none;
cursor: default;
}

Expand Down
2 changes: 1 addition & 1 deletion src/material/menu/menu.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('menu', () => {

it('should run not run click handlers on disabled menu items', async () => {
await page.trigger().click();
await page.items(2).click();
await browser.actions().mouseMove(page.items(2)).click();
expect(await page.getResultText()).toEqual('');
});

Expand Down
9 changes: 9 additions & 0 deletions src/material/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ $mat-menu-submenu-indicator-size: 10px !default;
@include mat-menu-item-base();
position: relative;

&[disabled] {
// Usually every click inside the menu closes it, however some browsers will stop events
// when the user clicks on a disabled item, **except** when the user clicks on a non-disabled
// child node of the disabled button. This is inconsistent because some regions of a disabled
// button will still cause the menu to close and some won't (see #16694). We make the behavior
// more consistent by disabling pointer events and allowing the user to click through.
pointer-events: none;
}

@include cdk-high-contrast {
&.cdk-program-focused,
&.cdk-keyboard-focused,
Expand Down