Skip to content

Commit 691bb73

Browse files
jelbournjosephperrott
authored andcommitted
chore(form-field): prevent overzealous floating placeholder rule optimization (#8343)
1 parent a019729 commit 691bb73

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/lib/form-field/_form-field-theme.scss

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@
105105
width: 100% / $font-scale;
106106
}
107107

108+
// This is a total duplicate of the mixin above with insignificant values added to the rules.
109+
// This exists because the mixin is used in two places. When Google's CSS Optimizer runs over this
110+
// css (after compiling from sass), it combines those two declarations into one. However, one of
111+
// those places uses `:-webkit-autofill`. When Firefox encounters this unknown pseuedo-class,
112+
// it ignores the entire rule. To work around this, we force one of the delcarations to be
113+
// technically different but still render the same by adding a tiny value to the transform / width.
114+
@mixin _mat-form-field-placeholder-float-nodedupe($font-scale, $infix-padding, $infix-margin-top) {
115+
transform: translateY(-$infix-margin-top - $infix-padding) scale($font-scale) perspective(100px)
116+
translateZ(0.002px);
117+
-ms-transform: translateY(-$infix-margin-top - $infix-padding) scale($font-scale);
118+
width: (100% / $font-scale) + 0.0001;
119+
}
120+
108121
@mixin mat-form-field-typography($config) {
109122
// The unit-less line-height from the font config.
110123
$line-height: mat-line-height($config, input);
@@ -182,7 +195,7 @@
182195

183196
.mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder-wrapper
184197
.mat-form-field-placeholder {
185-
@include _mat-form-field-placeholder-floating(
198+
@include _mat-form-field-placeholder-float-nodedupe(
186199
$subscript-font-scale, $infix-padding, $infix-margin-top);
187200
}
188201
}

0 commit comments

Comments
 (0)