Skip to content

Commit 8d5882c

Browse files
committed
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. (cherry picked from commit 00f743e)
1 parent a1a2347 commit 8d5882c

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
@@ -117,33 +117,36 @@ $legacy-border-radius: 2px !default;
117117

118118
// Overlay to be used as a tint.
119119
.mat-button-toggle-focus-overlay {
120+
@include layout-common.fill;
120121
border-radius: inherit;
121122

122123
// Disable pointer events to prevent it from hijacking user events.
123124
pointer-events: none;
124125
opacity: 0;
125-
@include layout-common.fill;
126+
}
126127

128+
@include cdk.high-contrast(active, off) {
127129
// Changing the background color for the selected item won't be visible in high contrast mode.
128130
// We fall back to using the overlay to draw a brighter, semi-transparent tint on top instead.
129131
// It uses a border, because the browser will render it using a brighter color.
130-
@include cdk.high-contrast(active, off) {
131-
.mat-button-toggle-checked & {
132+
.mat-button-toggle-checked {
133+
.mat-button-toggle-focus-overlay {
132134
border-bottom: solid $legacy-height;
133135
opacity: 0.5;
134136
height: 0;
135137
}
136-
}
137-
}
138138

139-
@include cdk.high-contrast(active, off) {
140-
.mat-button-toggle-checked.mat-button-toggle-appearance-standard
141-
.mat-button-toggle-focus-overlay {
142-
// In high contrast mode, we use a border for the checked state because backgrounds
143-
// can either be opaque or transparent. We set the border height to a value that is larger
144-
// than usual button toggles are. This allows us to keep this high contrast style in the
145-
// base component style, instead of making it dependent on height determined through density.
146-
border-bottom: solid 500px;
139+
&:hover .mat-button-toggle-focus-overlay {
140+
opacity: 0.6;
141+
}
142+
143+
&.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay {
144+
// In high contrast mode, we use a border for the checked state because backgrounds
145+
// can either be opaque or transparent. We set the border height to a value that is larger
146+
// than usual button toggles are. This allows us to keep this high contrast style in the
147+
// base component style, instead of making it dependent on height determined through density.
148+
border-bottom: solid 500px;
149+
}
147150
}
148151
}
149152

0 commit comments

Comments
 (0)