Skip to content

Commit 40a9101

Browse files
committed
fix(select,input): inconsistent disabled text color
* Fixes the select and input having different disabled text colors since the color isn't based on a palette. Adds a mixin to ensure that they can't get out of sync in the future. * Fixes the input having the wrong disabled text color (0.38 alpha for light themes and 0.5 for dark ones). It seems like the colors that were used before were in reference to the underline, not the text (see https://material.io/guidelines/components/text-fields.html#text-fields-states). Fixes #7793.
1 parent 9673f63 commit 40a9101

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/lib/core/style/_form-common.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@
66
background-size: 4px 1px;
77
background-repeat: repeat-x;
88
}
9+
10+
// Determines the text color of a disabled control since the values are not part of a palette.
11+
@mixin mat-control-disabled-text($theme) {
12+
$foreground: map-get($theme, foreground);
13+
$is-dark-theme: map-get($theme, is-dark);
14+
15+
color: mat-color($foreground, secondary-text, if($is-dark-theme, 0.5, 0.38));
16+
}

src/lib/input/_input-theme.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55

66

77
@mixin mat-input-theme($theme) {
8-
$foreground: map-get($theme, foreground);
9-
$is-dark-theme: map-get($theme, is-dark);
10-
118
.mat-input-element:disabled {
12-
color: mat-color($foreground, secondary-text, if($is-dark-theme, 0.7, 0.42));
9+
@include mat-control-disabled-text($theme);
1310
}
1411
}
1512

src/lib/select/_select-theme.scss

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
$primary: map-get($theme, primary);
1111
$accent: map-get($theme, accent);
1212
$warn: map-get($theme, warn);
13-
$is-dark-theme: map-get($theme, is-dark);
14-
15-
.mat-select-disabled .mat-select-value,
16-
.mat-select-arrow {
17-
color: mat-color($foreground, secondary-text);
18-
}
1913

2014
.mat-select-content, .mat-select-panel-done-animating {
2115
background: mat-color($background, card);
@@ -25,6 +19,14 @@
2519
color: mat-color($foreground, text);
2620
}
2721

22+
.mat-select-disabled .mat-select-value {
23+
@include mat-control-disabled-text($theme);
24+
}
25+
26+
.mat-select-arrow {
27+
color: mat-color($foreground, secondary-text);
28+
}
29+
2830
.mat-select-panel {
2931
.mat-option.mat-selected:not(.mat-option-multiple) {
3032
background: mat-color($background, hover, 0.12);
@@ -51,13 +53,9 @@
5153
}
5254

5355
.mat-select.mat-select-disabled .mat-select-arrow {
54-
color: mat-color($foreground, secondary-text);
56+
@include mat-control-disabled-text($theme);
5557
}
5658
}
57-
58-
.mat-select.mat-select-disabled .mat-select-arrow {
59-
color: mat-color($warn);
60-
}
6159
}
6260

6361
@mixin mat-select-typography($config) {

0 commit comments

Comments
 (0)