Skip to content

Commit e6578d9

Browse files
crisbetoannieyw
authored andcommitted
fix(material-experimental/mdc-checkbox): add focus indication in high contrast mode
Adds focus indication in high contrast mode to the MDC-based checkbox since currently it's impossible to know whether the element is focused.
1 parent 205a2f5 commit e6578d9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@use 'sass:map';
55
@use '../mdc-helpers/mdc-helpers';
66
@use '../../material/core/style/_layout-common.scss';
7+
@use '../../cdk/a11y/a11y';
78
@import '@material/checkbox/functions.import';
89
@import '@material/checkbox/mixins.import';
910
@import '@material/form-field/mixins.import';
@@ -27,8 +28,7 @@
2728
// The MDC checkbox styles related to the hover state are intertwined with the MDC ripple styles.
2829
// We currently don't use the MDC ripple due to size concerns, therefore we need to add some
2930
// additional styles to restore the hover state.
30-
.mdc-checkbox:hover
31-
.mdc-checkbox__native-control:not([disabled]) ~ .mdc-checkbox__ripple {
31+
.mdc-checkbox:hover .mdc-checkbox__native-control:not([disabled]) ~ .mdc-checkbox__ripple {
3232
opacity: map.get($mdc-ripple-dark-ink-opacities, hover);
3333
transform: scale(1);
3434
transition: mdc-checkbox-transition-enter(opacity, 0, 80ms),
@@ -37,10 +37,14 @@
3737

3838
// Note that the :not([disabled]) here isn't necessary, but we need it for the
3939
// extra specificity so that the hover styles don't override the focus styles.
40-
.mdc-checkbox
41-
.mdc-checkbox__native-control:not([disabled]):focus ~ .mdc-checkbox__ripple {
40+
.mdc-checkbox .mdc-checkbox__native-control:not([disabled]):focus ~ .mdc-checkbox__ripple {
4241
opacity: map.get($mdc-ripple-dark-ink-opacities, hover) +
4342
map.get($mdc-ripple-dark-ink-opacities, focus);
43+
44+
@include a11y.high-contrast(active, off) {
45+
outline: solid 3px;
46+
opacity: 1;
47+
}
4448
}
4549

4650
// Angular Material supports disabling all animations when NoopAnimationsModule is imported.

0 commit comments

Comments
 (0)