Skip to content

Commit ec44c90

Browse files
committed
fix(material-experimental/mdc-list): add high contrast mode treatment
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 db6511b commit ec44c90

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use '../mdc-helpers/mdc-helpers';
22
@use '../../material/core/style/layout-common';
3+
@use '../../cdk/a11y/a11y';
34
@import '@material/list/mixins.import';
45
@import '@material/list/variables.import';
56

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

0 commit comments

Comments
 (0)