@@ -49,13 +49,24 @@ $mat-form-field-legacy-dedupe: 0;
4949 // The tricks above used to smooth out the animation on chrome and firefox actually make things
5050 // worse on IE, so we don't include them in the IE version.
5151 -ms-transform : translateY (- $infix-margin-top - $infix-padding + $mat-form-field-legacy-dedupe )
52- scale ($font-scale );
52+ scale ($font-scale );
5353
5454 width : 100% / $font-scale + $mat-form-field-legacy-dedupe ;
5555
5656 $mat-form-field-legacy-dedupe : $mat-form-field-legacy-dedupe + 0.00001 !global;
5757}
5858
59+ // Same as mixin above, but omits the translateZ for printing purposes.
60+ @mixin _mat-form-field-legacy-label-floating-print ($font-scale , $infix-padding , $infix-margin-top ) {
61+ // This results in a small jitter after the label floats on Firefox, which the
62+ // translateZ fixes.
63+ transform : translateY (- $infix-margin-top - $infix-padding + $mat-form-field-legacy-dedupe )
64+ scale ($font-scale );
65+ // The tricks above used to smooth out the animation on chrome and firefox actually make things
66+ // worse on IE, so we don't include them in the IE version.
67+ $mat-form-field-legacy-dedupe : $mat-form-field-legacy-dedupe + 0.00001 !global;
68+ }
69+
5970@mixin mat-form-field-legacy-typography ($config ) {
6071 // The unit-less line-height from the font config.
6172 $line-height : mat-line-height ($config , input );
@@ -130,4 +141,33 @@ $mat-form-field-legacy-dedupe: 0;
130141 top : calc (100% - #{$wrapper-padding-bottom / $subscript-font-scale } );
131142 }
132143 }
144+
145+ // translateZ causes the label to not appear while printing, so we override it to not
146+ // apply translateZ while printing
147+ @media print {
148+ .mat-form-field-appearance-legacy {
149+ & .mat-form-field-can-float {
150+ & .mat-form-field-should-float .mat-form-field-label ,
151+ .mat-input-server :focus + .mat-form-field-label-wrapper .mat-form-field-label {
152+ @include _mat-form-field-legacy-label-floating-print (
153+ $subscript-font-scale , $infix-padding , $infix-margin-top );
154+ }
155+
156+ // @breaking-change 7.0.0 will rely on AutofillMonitor instead.
157+ .mat-form-field-autofill-control :-webkit-autofill + .mat-form-field-label-wrapper
158+ .mat-form-field-label {
159+ @include _mat-form-field-legacy-label-floating-print (
160+ $subscript-font-scale , $infix-padding , $infix-margin-top );
161+ }
162+
163+ // Server-side rendered matInput with a label attribute but label not shown
164+ // (used as a pure CSS stand-in for mat-form-field-should-float).
165+ .mat-input-server [label ]:not (:label-shown ) + .mat-form-field-label-wrapper
166+ .mat-form-field-label {
167+ @include _mat-form-field-legacy-label-floating-print (
168+ $subscript-font-scale , $infix-padding , $infix-margin-top );
169+ }
170+ }
171+ }
172+ }
133173}
0 commit comments