@@ -1127,6 +1127,30 @@ describe('MatInput with appearance', () => {
1127
1127
expect ( testComponent . formField . floatLabel ) . toBe ( 'auto' ) ;
1128
1128
}
1129
1129
} ) ) ;
1130
+
1131
+ it ( 'should recalculate gaps when switching to outline appearance after init' , fakeAsync ( ( ) => {
1132
+ fixture . destroy ( ) ;
1133
+ TestBed . resetTestingModule ( ) ;
1134
+
1135
+ const outlineFixture = createComponent ( MatInputWithAppearanceAndLabel ) ;
1136
+
1137
+ outlineFixture . detectChanges ( ) ;
1138
+ outlineFixture . componentInstance . appearance = 'legacy' ;
1139
+ outlineFixture . detectChanges ( ) ;
1140
+ flush ( ) ;
1141
+
1142
+ outlineFixture . componentInstance . appearance = 'outline' ;
1143
+ outlineFixture . detectChanges ( ) ;
1144
+ flush ( ) ;
1145
+ outlineFixture . detectChanges ( ) ;
1146
+
1147
+ const wrapperElement = outlineFixture . nativeElement ;
1148
+ const outlineStart = wrapperElement . querySelector ( '.mat-form-field-outline-start' ) ;
1149
+ const outlineGap = wrapperElement . querySelector ( '.mat-form-field-outline-gap' ) ;
1150
+
1151
+ expect ( parseInt ( outlineStart . style . width ) ) . toBeGreaterThan ( 0 ) ;
1152
+ expect ( parseInt ( outlineGap . style . width ) ) . toBeGreaterThan ( 0 ) ;
1153
+ } ) ) ;
1130
1154
} ) ;
1131
1155
1132
1156
describe ( 'MatFormField default options' , ( ) => {
@@ -1567,6 +1591,18 @@ class MatInputWithAppearance {
1567
1591
appearance : MatFormFieldAppearance ;
1568
1592
}
1569
1593
1594
+ @Component ( {
1595
+ template : `
1596
+ <mat-form-field [appearance]="appearance">
1597
+ <mat-label>Label</mat-label>
1598
+ <input matInput>
1599
+ </mat-form-field>
1600
+ `
1601
+ } )
1602
+ class MatInputWithAppearanceAndLabel {
1603
+ appearance : MatFormFieldAppearance ;
1604
+ }
1605
+
1570
1606
@Component ( {
1571
1607
template : `
1572
1608
<mat-form-field>
0 commit comments