Skip to content

Commit 4f8e87e

Browse files
authored
fix(material-experimental/mdc-list): add high contrast mode treatment (#21376)
Adds similar high contrast mode treatment to the non-MDC list since the MDC implementation suffers from the same issues we had resolved before.
1 parent f65d5b5 commit 4f8e87e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

+33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use '@material/list' as mdc-list;
22
@use '../mdc-helpers/mdc-helpers';
33
@use '../../material/core/style/layout-common';
4+
@use '../../cdk/a11y/a11y';
45

56
@include mdc-list.deprecated-without-ripple($query: mdc-helpers.$mat-base-styles-query);
67

@@ -124,3 +125,35 @@
124125
@include layout-common.fill();
125126
pointer-events: none;
126127
}
128+
129+
130+
@include a11y.high-contrast(active, off) {
131+
.mat-mdc-list-option,
132+
.mat-mdc-nav-list .mat-mdc-list-item,
133+
.mat-mdc-action-list .mat-mdc-list-item {
134+
&:hover, &:focus {
135+
outline: dotted 1px;
136+
}
137+
}
138+
139+
// In single selection mode, the selected option is indicated by changing its
140+
// background color, but that doesn't work in high contrast mode. We add an
141+
// alternate indication by rendering out a circle.
142+
.mat-mdc-list-option.mdc-list-item--selected::after {
143+
$size: 10px;
144+
content: '';
145+
position: absolute;
146+
top: 50%;
147+
right: mdc-list.$deprecated-side-padding;
148+
transform: translateY(-50%);
149+
width: $size;
150+
height: 0;
151+
border-bottom: solid $size;
152+
border-radius: $size;
153+
}
154+
155+
[dir='rtl'] .mat-mdc-list-option.mdc-list-item--selected::after {
156+
right: auto;
157+
left: mdc-list.$deprecated-side-padding;
158+
}
159+
}

0 commit comments

Comments
 (0)