Skip to content

Commit 2fccb47

Browse files
committed
fix(menu): remove pointer-events from disabled mat-menu for consistent behavior
1 parent bfd7a47 commit 2fccb47

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

Diff for: src/material/menu/_m2-menu.scss

+15-10
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,31 @@ $prefix: (mat, menu);
2020
item-with-icon-leading-spacing: 16px,
2121
item-with-icon-trailing-spacing: 16px,
2222
container-elevation-shadow: elevation.get-box-shadow(8),
23-
2423
// Unused
25-
base-elevation-level: null,
24+
base-elevation-level: null
2625
);
2726
}
2827

2928
// Tokens that can be configured through Angular Material's color theming API.
3029
@function get-color-tokens($theme) {
3130
$is-dark: inspection.get-theme-type($theme) == dark;
32-
$active-state-layer-color: inspection.get-theme-color($theme, foreground, base,
33-
if($is-dark, 0.08, 0.04));
31+
$active-state-layer-color: inspection.get-theme-color(
32+
$theme,
33+
foreground,
34+
base,
35+
if($is-dark, 0.08, 0.04)
36+
);
37+
$disabled-background: inspection.get-theme-color($theme, foreground, disabled-button);
3438
$text-color: inspection.get-theme-color($theme, foreground, text);
3539

3640
@return (
3741
item-label-text-color: $text-color,
3842
item-icon-color: $text-color,
3943
item-hover-state-layer-color: $active-state-layer-color,
44+
item-disabled-hover-state-layer-color: $disabled-background,
4045
item-focus-state-layer-color: $active-state-layer-color,
4146
container-color: inspection.get-theme-color($theme, background, card),
42-
divider-color: inspection.get-theme-color($theme, foreground, divider),
47+
divider-color: inspection.get-theme-color($theme, foreground, divider)
4348
);
4449
}
4550

@@ -50,7 +55,7 @@ $prefix: (mat, menu);
5055
item-label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
5156
item-label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
5257
item-label-text-line-height: inspection.get-theme-typography($theme, body-1, line-height),
53-
item-label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
58+
item-label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight)
5459
);
5560
}
5661

@@ -63,9 +68,9 @@ $prefix: (mat, menu);
6368
// This is used to create token slots.
6469
@function get-token-slots() {
6570
@return sass-utils.deep-merge-all(
66-
get-unthemable-tokens(),
67-
get-color-tokens(m2-utils.$placeholder-color-config),
68-
get-typography-tokens(m2-utils.$placeholder-typography-config),
69-
get-density-tokens(m2-utils.$placeholder-density-config)
71+
get-unthemable-tokens(),
72+
get-color-tokens(m2-utils.$placeholder-color-config),
73+
get-typography-tokens(m2-utils.$placeholder-typography-config),
74+
get-density-tokens(m2-utils.$placeholder-density-config)
7075
);
7176
}

Diff for: src/material/menu/_m3-menu.scss

+11-8
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ $prefix: (mat, menu);
2323
item-icon-color: map.get($systems, md-sys-color, on-surface-variant),
2424
item-icon-size: m3-utils.hardcode(24px, $exclude-hardcoded),
2525
item-hover-state-layer-color: sass-utils.safe-color-change(
26-
map.get($systems, md-sys-color, on-surface),
27-
$alpha: map.get($systems, md-sys-state, hover-state-layer-opacity)
28-
),
26+
map.get($systems, md-sys-color, on-surface),
27+
$alpha: map.get($systems, md-sys-state, hover-state-layer-opacity)
28+
),
29+
item-disabled-hover-state-layer-color: sass-utils.safe-color-change(
30+
map.get($systems, md-sys-color, n-surface),
31+
$alpha: 0.38
32+
),
2933
item-focus-state-layer-color: sass-utils.safe-color-change(
30-
map.get($systems, md-sys-color, on-surface),
31-
$alpha: map.get($systems, md-sys-state, focus-state-layer-opacity)
32-
),
34+
map.get($systems, md-sys-color, on-surface),
35+
$alpha: map.get($systems, md-sys-state, focus-state-layer-opacity)
36+
),
3337
item-spacing: m3-utils.hardcode(12px, $exclude-hardcoded),
3438
item-leading-spacing: m3-utils.hardcode(12px, $exclude-hardcoded),
3539
item-trailing-spacing: m3-utils.hardcode(12px, $exclude-hardcoded),
3640
item-with-icon-leading-spacing: m3-utils.hardcode(12px, $exclude-hardcoded),
3741
item-with-icon-trailing-spacing: m3-utils.hardcode(12px, $exclude-hardcoded),
3842
container-color: map.get($systems, md-sys-color, surface-container),
39-
container-elevation-shadow: m3-utils.hardcode(
40-
elevation.get-box-shadow(2), $exclude-hardcoded),
43+
container-elevation-shadow: m3-utils.hardcode(elevation.get-box-shadow(2), $exclude-hardcoded),
4144
)
4245
);
4346

Diff for: src/material/menu/menu.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ mat-menu {
180180
&[disabled] {
181181
cursor: default;
182182
opacity: 0.38;
183-
pointer-events: none;
184183

185184
// The browser prevents clicks on disabled buttons from propagating which prevents the menu
186185
// from closing, but clicks on child nodes still propagate which is inconsistent (see #16694).
@@ -201,7 +200,7 @@ mat-menu {
201200
pointer-events: auto;
202201

203202
&:hover {
204-
background-color: token-utils.slot(item-hover-state-layer-color);
203+
background-color: token-utils.slot(item-disabled-hover-state-layer-color);
205204
}
206205

207206
&.cdk-program-focused,

0 commit comments

Comments
 (0)