Skip to content

Commit 881b013

Browse files
wagnermacielamysorto
authored andcommitted
fix(material-experimental/mdc-menu): increase specificity of menu panel styles (#23178)
* We had some order-dependent styles that would be overridden if MDCs styles got loaded after ours. We are increasing the specificity of the menu panel styles to prevent these styles from being overriden when this edge case is hit (cherry picked from commit a81834a)
1 parent ecac3b5 commit 881b013

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/material-experimental/mdc-menu/menu.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ mat-menu {
1919
}
2020

2121
.mat-mdc-menu-panel {
22+
@include a11y.high-contrast(active, off) {
23+
outline: solid 1px;
24+
}
25+
}
26+
27+
// We need to increase the specificity for these styles to ensure we are not overriden by MDC's
28+
// .mdc-menu-surface styles. This can happen if the MDC styles are loaded in after our styles.
29+
.mat-mdc-menu-panel.mat-mdc-menu-panel {
2230
// Include Material's base menu panel styling which contain the `min-width`, `max-width` and some
2331
// styling to make scrolling smoother. MDC doesn't include the `min-width` and `max-width`, even
2432
// though they're explicitly defined in spec.
2533
@include menu-common.base;
2634

2735
// The CDK positioning uses flexbox to anchor the element, whereas MDC uses `position: absolute`.
2836
position: static;
29-
30-
@include a11y.high-contrast(active, off) {
31-
outline: solid 1px;
32-
}
3337
}
3438

3539
.mat-mdc-menu-item {

0 commit comments

Comments
 (0)