Skip to content

Commit 1c39b72

Browse files
crisbetojelbourn
authored andcommitted
fix(material/button): add more prominent focus indication in high contrast mode (#20821)
We currently have some focus indication in high contrast mode, but it's very difficult to see. These changes replace the old one with a 3x thicker outline. Fixes #20820. (cherry picked from commit 345ad70)
1 parent d123a4d commit 1c39b72

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
}
2525
}
2626

27+
@include cdk-high-contrast(active, off) {
28+
.mat-mdc-button-base:focus {
29+
outline: solid 3px;
30+
}
31+
}
32+
2733
// Since the stroked button has has an actual border that reduces the available space for
2834
// child elements such as the ripple container or focus overlay, an inherited border radius
2935
// for the absolute-positioned child elements does not work properly. This is because the

src/material/button/button.scss

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,6 @@
120120
._mat-animation-noopable & {
121121
transition: none;
122122
}
123-
124-
@include cdk-high-contrast(active, off) {
125-
// Note that IE will render this in the same way, no
126-
// matter whether the theme is light or dark. This helps
127-
// with the readability of focused buttons.
128-
background-color: #fff;
129-
}
130-
131-
@include cdk-high-contrast(black-on-white, off) {
132-
// For the black-on-white high contrast mode, the browser will set this element
133-
// to white, making it blend in with the background, hence why we need to set
134-
// it explicitly to black.
135-
background-color: #000;
136-
}
137123
}
138124

139125
// For round buttons, the ripple container should clip child ripples to a circle.
@@ -171,4 +157,10 @@
171157
.mat-button, .mat-flat-button, .mat-raised-button, .mat-icon-button, .mat-fab, .mat-mini-fab {
172158
outline: solid 1px;
173159
}
160+
161+
.mat-button-base {
162+
&.cdk-keyboard-focused, &.cdk-program-focused {
163+
outline: solid 3px;
164+
}
165+
}
174166
}

0 commit comments

Comments
 (0)