Skip to content

Commit 00f743e

Browse files
authored
fix(material/button-toggle): selected state not visible in high contrast mode (#25114)
It looks like at some point we regressed to where the selected indication in high contrast mode became transparent.
1 parent 1f22b09 commit 00f743e

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/material/button-toggle/button-toggle.scss

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,33 +108,36 @@ $legacy-border-radius: 2px !default;
108108

109109
// Overlay to be used as a tint.
110110
.mat-button-toggle-focus-overlay {
111+
@include layout-common.fill;
111112
border-radius: inherit;
112113

113114
// Disable pointer events to prevent it from hijacking user events.
114115
pointer-events: none;
115116
opacity: 0;
116-
@include layout-common.fill;
117+
}
117118

119+
@include cdk.high-contrast(active, off) {
118120
// Changing the background color for the selected item won't be visible in high contrast mode.
119121
// We fall back to using the overlay to draw a brighter, semi-transparent tint on top instead.
120122
// It uses a border, because the browser will render it using a brighter color.
121-
@include cdk.high-contrast(active, off) {
122-
.mat-button-toggle-checked & {
123+
.mat-button-toggle-checked {
124+
.mat-button-toggle-focus-overlay {
123125
border-bottom: solid $legacy-height;
124126
opacity: 0.5;
125127
height: 0;
126128
}
127-
}
128-
}
129129

130-
@include cdk.high-contrast(active, off) {
131-
.mat-button-toggle-checked.mat-button-toggle-appearance-standard
132-
.mat-button-toggle-focus-overlay {
133-
// In high contrast mode, we use a border for the checked state because backgrounds
134-
// can either be opaque or transparent. We set the border height to a value that is larger
135-
// than usual button toggles are. This allows us to keep this high contrast style in the
136-
// base component style, instead of making it dependent on height determined through density.
137-
border-bottom: solid 500px;
130+
&:hover .mat-button-toggle-focus-overlay {
131+
opacity: 0.6;
132+
}
133+
134+
&.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay {
135+
// In high contrast mode, we use a border for the checked state because backgrounds
136+
// can either be opaque or transparent. We set the border height to a value that is larger
137+
// than usual button toggles are. This allows us to keep this high contrast style in the
138+
// base component style, instead of making it dependent on height determined through density.
139+
border-bottom: solid 500px;
140+
}
138141
}
139142
}
140143

0 commit comments

Comments
 (0)