Skip to content

Commit e180655

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 032c317 commit e180655

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
@@ -79,10 +79,16 @@
7979
}
8080

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

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)