Skip to content

Commit 19b8934

Browse files
authored
fix(material/form-field): use correct color for form fields in high contrast mode (#24422)
Fixes that we weren't using the correct colors for disabled form field in high contrast mode on Windows.
1 parent dbcd140 commit 19b8934

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

src/material-experimental/mdc-form-field/_form-field-high-contrast.scss

+14-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
$focus-indicator-width: 3px;
55
$focus-indicator-style: dashed;
66

7-
// The outline of the `fill` appearance is achieved through a background color
8-
// which won't be visible in high contrast mode. Add an outline to replace it.
9-
.mat-form-field-appearance-fill .mat-mdc-text-field-wrapper {
10-
@include a11y.high-contrast(active, off) {
11-
outline: solid 1px;
7+
.mat-form-field-appearance-fill {
8+
// The outline of the `fill` appearance is achieved through a background color
9+
// which won't be visible in high contrast mode. Add an outline to replace it.
10+
.mat-mdc-text-field-wrapper {
11+
@include a11y.high-contrast(active, off) {
12+
outline: solid 1px;
13+
}
14+
}
15+
16+
// Use GreyText for the disabled outline color which will account for the user's configuration.
17+
&.mat-form-field-disabled .mat-mdc-text-field-wrapper {
18+
@include a11y.high-contrast(active, off) {
19+
outline-color: GrayText;
20+
}
1221
}
1322
}
1423

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

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ $scale: 0.75 !default;
7777
// On Chromium browsers the `currentColor` blends in with the
7878
// background for SVGs so we have to fall back to `CanvasText`.
7979
fill: CanvasText;
80+
81+
.mat-mdc-select-disabled & {
82+
fill: GrayText;
83+
}
8084
}
8185
}
8286
}

src/material/form-field/form-field-fill.scss

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ $fill-subscript-padding: math.div($fill-side-padding, $fill-subscript-font-scale
3232
}
3333
}
3434

35+
&.mat-form-field-disabled .mat-form-field-flex {
36+
@include a11y.high-contrast(active, off) {
37+
outline-color: GrayText;
38+
}
39+
}
40+
3541
&.mat-focused .mat-form-field-flex {
3642
@include a11y.high-contrast(active, off) {
3743
outline: dashed 3px;

src/material/form-field/form-field-legacy.scss

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ $legacy-underline-height: 1px !default;
6363
@include a11y.high-contrast(active, off) {
6464
border-top-style: dotted;
6565
border-top-width: 2px;
66+
border-top-color: GrayText;
6667
}
6768
}
6869

src/material/form-field/form-field-outline.scss

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ $outline-subscript-padding: math.div($outline-side-padding, $outline-subscript-f
138138
padding: 0 $outline-subscript-padding;
139139
}
140140

141+
&.mat-form-field-disabled .mat-form-field-outline {
142+
@include a11y.high-contrast(active, off) {
143+
color: GrayText;
144+
}
145+
}
146+
141147
&._mat-animation-noopable {
142148
&:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-outline,
143149
.mat-form-field-outline,

src/material/form-field/form-field.scss

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ $default-infix-width: 180px !default;
112112
left: auto;
113113
right: 0;
114114
}
115+
116+
.mat-form-field-disabled & {
117+
@include a11y.high-contrast(active, off) {
118+
color: GrayText;
119+
}
120+
}
115121
}
116122

117123
.mat-form-field-empty.mat-form-field-label,

0 commit comments

Comments
 (0)