Skip to content

Commit

Permalink
fix(material-experimental/mdc-list): add selected indication in high …
Browse files Browse the repository at this point in the history
…contrast mode (#22447)

When a list option is selected in single selection mode, it changes its background color to stand out. This doesn't work in high contrast mode so these changes port over the workaround that we have from the non-MDC list.
  • Loading branch information
crisbeto committed Apr 19, 2021
1 parent a0a77d7 commit 5e42d15
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/material-experimental/mdc-list/list-option.scss
@@ -1,5 +1,7 @@
@use '@material/checkbox' as mdc-checkbox;
@use '@material/list' as mdc-list;
@use '../mdc-helpers/mdc-helpers';
@use '../../cdk/a11y';

// The MDC-based list-option uses the MDC checkbox for the selection indicators.
// We need to ensure that the checkbox styles are included for the list-option.
Expand All @@ -14,3 +16,26 @@
.mat-mdc-list-option .mdc-checkbox__native-control {
display: none;
}

@include a11y.high-contrast(active, off) {
// In single selection mode, the selected option is indicated by changing its
// background color, but that doesn't work in high contrast mode. We add an
// alternate indication by rendering out a circle.
.mat-mdc-list-option.mdc-deprecated-list-item--selected::after {
$size: 10px;
content: '';
position: absolute;
top: 50%;
right: mdc-list.$deprecated-side-padding;
transform: translateY(-50%);
width: $size;
height: 0;
border-bottom: solid $size;
border-radius: $size;
}

[dir='rtl'] .mat-mdc-list-option.mdc-deprecated-list-item--selected::after {
right: auto;
left: mdc-list.$deprecated-side-padding;
}
}

0 comments on commit 5e42d15

Please sign in to comment.