@@ -1127,6 +1127,30 @@ describe('MatInput with appearance', () => {
11271127 expect ( testComponent . formField . floatLabel ) . toBe ( 'auto' ) ;
11281128 }
11291129 } ) ) ;
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+ } ) ) ;
11301154} ) ;
11311155
11321156describe ( 'MatFormField default options' , ( ) => {
@@ -1567,6 +1591,18 @@ class MatInputWithAppearance {
15671591 appearance : MatFormFieldAppearance ;
15681592}
15691593
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+
15701606@Component ( {
15711607 template : `
15721608 <mat-form-field>
0 commit comments