Skip to content

Commit caad0b5

Browse files
devversionandrewseguin
authored andcommitted
refactor(material-experimental/mdc-form-field): disambiguate mixin names from non-mdc form-field
Mixins like `_mat-form-field-density` also exist in the non-mdc form-field implementation. Even though there might be no density styles there, the actual MDC-based from-field will loose its default density styles and render incorrectly.
1 parent 82f4560 commit caad0b5

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

src/material-experimental/mdc-form-field/_form-field-density.scss

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Mixin that sets the vertical spacing for the infix container of filled form fields.
66
// We need to apply spacing to the infix container because we removed the input padding
77
// provided by MDC in order to support arbitrary form-field controls.
8-
@mixin _mat-form-field-infix-vertical-spacing-filled($with-label-padding, $no-label-padding) {
8+
@mixin _mat-mdc-form-field-infix-vertical-spacing-filled($with-label-padding, $no-label-padding) {
99
.mat-mdc-text-field-wrapper:not(.mdc-text-field--outlined) .mat-mdc-form-field-infix {
1010
padding-top: map_get($with-label-padding, top);
1111
padding-bottom: map_get($with-label-padding, bottom);
@@ -21,7 +21,7 @@
2121
// Mixin that sets the vertical spacing for the infix container of outlined form fields.
2222
// We need to apply spacing to the infix container because we removed the input padding
2323
// provided by MDC in order to support arbitrary form-field controls.
24-
@mixin _mat-form-field-infix-vertical-spacing-outlined($padding) {
24+
@mixin _mat-mdc-form-field-infix-vertical-spacing-outlined($padding) {
2525
.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix {
2626
padding-top: map_get($padding, top);
2727
padding-bottom: map_get($padding, bottom);
@@ -35,7 +35,7 @@
3535
// provide spacing that makes arbitrary controls align as specified in the Material Design
3636
// specification. In order to support density, we need to adjust the vertical spacing to be
3737
// based on the density scale.
38-
@mixin _mat-form-field-density($config-or-theme) {
38+
@mixin _mat-mdc-form-field-density($config-or-theme) {
3939
$density-scale: mat-get-density-config($config-or-theme);
4040
// Height of the form field that is based on the current density scale.
4141
$height: mdc-density-prop-value(
@@ -96,13 +96,14 @@
9696
// aligned as if there is no label. This is done similarly in MDC and is specified in the
9797
// Material Design specification. Outline form fields position the control as if there is no
9898
// label. This is because the label overflows the form-field and doesn't need space at the top.
99-
@include _mat-form-field-infix-vertical-spacing-outlined($no-label-padding);
99+
@include _mat-mdc-form-field-infix-vertical-spacing-outlined($no-label-padding);
100100

101101
// MDC hides labels for filled form fields when the form field height decreases. We match
102102
// this behavior in our custom density styles.
103103
@if $hide-filled-floating-label {
104104
// Update the spacing for filled form fields to account for the hidden floating label.
105-
@include _mat-form-field-infix-vertical-spacing-filled($no-label-padding, $no-label-padding);
105+
@include _mat-mdc-form-field-infix-vertical-spacing-filled(
106+
$no-label-padding, $no-label-padding);
106107
.mat-mdc-text-field-wrapper:not(.mdc-text-field--outlined) .mdc-floating-label {
107108
display: none;
108109
}
@@ -111,6 +112,7 @@
111112
// By default, filled form fields align their controls differently based on whether there
112113
// is a label or not. MDC does this too, but we cannot rely on their styles as we support
113114
// arbitrary form field controls and MDC only applies their spacing to the `<input>` elements.
114-
@include _mat-form-field-infix-vertical-spacing-filled($with-label-padding, $no-label-padding);
115+
@include _mat-mdc-form-field-infix-vertical-spacing-filled(
116+
$with-label-padding, $no-label-padding);
115117
}
116118
}

src/material-experimental/mdc-form-field/_form-field-focus-overlay.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// runtime code for launching interaction ripples at pointer location. This is not needed
1010
// for the text-field, so we create our own minimal focus overlay styles. Our focus overlay
1111
// uses the exact same logic to compute the colors as in the default MDC text-field ripples.
12-
@mixin _mat-form-field-focus-overlay() {
12+
@mixin _mat-mdc-form-field-focus-overlay() {
1313
.mat-mdc-form-field-focus-overlay {
1414
@include mat-fill;
1515
opacity: 0;
1616
}
1717
}
1818

19-
@mixin _mat-form-field-focus-overlay-color() {
19+
@mixin _mat-mdc-form-field-focus-overlay-color() {
2020
$focus-opacity: ripple-functions.states-opacity($mdc-text-field-ink-color, focus);
2121
$hover-opacity: ripple-functions.states-opacity($mdc-text-field-ink-color, hover);
2222

src/material-experimental/mdc-form-field/_form-field-native-select.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $mat-form-field-select-arrow-height: 5px;
1010
$mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-width + 5px;
1111

1212
// Mixin that creates styles for native select controls in a form-field.
13-
@mixin _mat-form-field-native-select() {
13+
@mixin _mat-mdc-form-field-native-select() {
1414
// Remove the native select down arrow and ensure that the native appearance
1515
// does not conflict with the form-field. e.g. Focus indication of the native
1616
// select is undesired since we handle focus as part of the form-field.
@@ -90,7 +90,7 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
9090
}
9191
}
9292

93-
@mixin _mat-form-field-native-select-color($config) {
93+
@mixin _mat-mdc-form-field-native-select-color($config) {
9494
select.mat-mdc-input-element {
9595
// On dark themes we set the native `select` color to some shade of white,
9696
// however the color propagates to all of the `option` elements, which are

src/material-experimental/mdc-form-field/_form-field-subscript.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import 'form-field-sizing';
22
@import '../mdc-helpers/mdc-helpers';
33

4-
@mixin _mat-form-field-subscript() {
4+
@mixin _mat-mdc-form-field-subscript() {
55
// Wrapper for the hints and error messages.
66
.mat-mdc-form-field-subscript-wrapper {
77
box-sizing: border-box;
@@ -34,14 +34,14 @@
3434
}
3535
}
3636

37-
@mixin _mat-form-field-subscript-color() {
37+
@mixin _mat-mdc-form-field-subscript-color() {
3838
// MDC does not have built-in error treatment.
3939
.mat-mdc-form-field-error {
4040
@include mdc-theme-prop(color, $mdc-text-field-error);
4141
}
4242
}
4343

44-
@mixin _mat-form-field-subscript-typography($config-or-theme) {
44+
@mixin _mat-mdc-form-field-subscript-typography($config-or-theme) {
4545
$config: mat-get-typography-config($config-or-theme);
4646
// The unit-less line-height from the font config.
4747
$line-height: mat-line-height($config, input);

src/material-experimental/mdc-form-field/_form-field-theme.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
@include mdc-floating-label-core-styles($query: $mat-theme-styles-query);
4444
@include mdc-notched-outline-core-styles($query: $mat-theme-styles-query);
4545
@include mdc-line-ripple-core-styles($query: $mat-theme-styles-query);
46-
@include _mat-form-field-subscript-color();
47-
@include _mat-form-field-focus-overlay-color();
48-
@include _mat-form-field-native-select-color($config);
46+
@include _mat-mdc-form-field-subscript-color();
47+
@include _mat-mdc-form-field-focus-overlay-color();
48+
@include _mat-mdc-form-field-native-select-color($config);
4949

5050
.mat-mdc-form-field.mat-accent {
5151
@include _mdc-text-field-color-styles(secondary);
@@ -65,7 +65,7 @@
6565
@include mdc-floating-label-core-styles($query: $mat-typography-styles-query);
6666
@include mdc-notched-outline-core-styles($query: $mat-typography-styles-query);
6767
@include mdc-line-ripple-core-styles($query: $mat-typography-styles-query);
68-
@include _mat-form-field-subscript-typography($config);
68+
@include _mat-mdc-form-field-subscript-typography($config);
6969

7070
.mat-mdc-form-field {
7171
@include mat-typography-level-to-styles($config, input);
@@ -75,7 +75,7 @@
7575

7676
@mixin mat-mdc-form-field-density($config-or-theme) {
7777
$density-scale: mat-get-density-config($config-or-theme);
78-
@include _mat-form-field-density($density-scale);
78+
@include _mat-mdc-form-field-density($density-scale);
7979
}
8080

8181
@mixin mat-mdc-form-field-theme($theme-or-color-config) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
@include _mat-mdc-text-field-structure-overrides();
1919

2020
// Include the subscript, focus-overlay and native select styles.
21-
@include _mat-form-field-subscript();
22-
@include _mat-form-field-focus-overlay();
23-
@include _mat-form-field-native-select();
21+
@include _mat-mdc-form-field-subscript();
22+
@include _mat-mdc-form-field-focus-overlay();
23+
@include _mat-mdc-form-field-native-select();
2424

2525
// Host element of the form-field. It contains the mdc-text-field wrapper
2626
// and the subscript wrapper.

0 commit comments

Comments
 (0)