Skip to content

Commit e029ea8

Browse files
crisbetommalerba
authored andcommitted
fix(material/menu): focus indication rendering partially in high contrast mode (#21527)
Firefox seems to have an issue where the items cut off each other's outline in high contrast mode. These changes work around the issue by introducing a slight margin. Note that this isn't ideal, because the whole point of using an outline is so that the layout isn't different on high contrast mode. The alternate approach is to use a `border`, but it will cause the element to move around as the user is navigating. Fixes #21524. (cherry picked from commit bf34cdb)
1 parent 48830aa commit e029ea8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@
7878
}
7979

8080
@include cdk-high-contrast(active, off) {
81+
$outline-width: 1px;
82+
83+
// We need to move the item 1px down, because Firefox seems to have
84+
// an issue rendering the top part of the outline (see #21524).
85+
margin-top: $outline-width;
86+
8187
&.cdk-program-focused,
8288
&.cdk-keyboard-focused,
8389
&-highlighted {
84-
outline: dotted 1px;
90+
outline: dotted $outline-width;
8591
}
8692
}
8793
}

src/material/menu/menu.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@ $mat-menu-submenu-indicator-size: 10px !default;
5454
}
5555

5656
@include cdk-high-contrast(active, off) {
57+
$outline-width: 1px;
58+
59+
// We need to move the item 1px down, because Firefox seems to have
60+
// an issue rendering the top part of the outline (see #21524).
61+
margin-top: $outline-width;
62+
5763
&.cdk-program-focused,
5864
&.cdk-keyboard-focused,
5965
&-highlighted {
60-
outline: dotted 1px;
66+
outline: dotted $outline-width;
6167
}
6268
}
6369
}

0 commit comments

Comments
 (0)