@@ -945,6 +945,28 @@ describe('MDC-based MatAutocomplete', () => {
945
945
} ) ;
946
946
} ) ;
947
947
948
+ describe ( 'with theming' , ( ) => {
949
+ let fixture : ComponentFixture < SimpleAutocomplete > ;
950
+
951
+ beforeEach ( ( ) => {
952
+ fixture = createComponent ( SimpleAutocomplete ) ;
953
+ fixture . detectChanges ( ) ;
954
+ } ) ;
955
+
956
+ it ( 'should transfer the theme to the autocomplete panel' , ( ) => {
957
+ fixture . componentInstance . theme = 'warn' ;
958
+ fixture . detectChanges ( ) ;
959
+
960
+ fixture . componentInstance . trigger . openPanel ( ) ;
961
+ fixture . detectChanges ( ) ;
962
+
963
+ const panel = overlayContainerElement . querySelector (
964
+ '.mat-mdc-autocomplete-panel' ,
965
+ ) ! as HTMLElement ;
966
+ expect ( panel . classList ) . toContain ( 'mat-warn' ) ;
967
+ } ) ;
968
+ } ) ;
969
+
948
970
describe ( 'keyboard events' , ( ) => {
949
971
let fixture : ComponentFixture < SimpleAutocomplete > ;
950
972
let input : HTMLInputElement ;
@@ -3393,7 +3415,7 @@ describe('MDC-based MatAutocomplete', () => {
3393
3415
} ) ;
3394
3416
3395
3417
const SIMPLE_AUTOCOMPLETE_TEMPLATE = `
3396
- <mat-form-field [floatLabel]="floatLabel" [style.width.px]="width">
3418
+ <mat-form-field [floatLabel]="floatLabel" [style.width.px]="width" [color]="theme" >
3397
3419
<mat-label *ngIf="hasLabel">State</mat-label>
3398
3420
<input
3399
3421
matInput
@@ -3402,19 +3424,18 @@ const SIMPLE_AUTOCOMPLETE_TEMPLATE = `
3402
3424
[matAutocompletePosition]="position"
3403
3425
[matAutocompleteDisabled]="autocompleteDisabled"
3404
3426
[formControl]="stateCtrl">
3427
+ <mat-autocomplete [class]="panelClass" #auto="matAutocomplete" [displayWith]="displayFn"
3428
+ [disableRipple]="disableRipple" [aria-label]="ariaLabel" [aria-labelledby]="ariaLabelledby"
3429
+ (opened)="openedSpy()" (closed)="closedSpy()">
3430
+ <mat-option
3431
+ *ngFor="let state of filteredStates"
3432
+ [value]="state"
3433
+ [style.height.px]="state.height"
3434
+ [disabled]="state.disabled">
3435
+ <span>{{ state.code }}: {{ state.name }}</span>
3436
+ </mat-option>
3437
+ </mat-autocomplete>
3405
3438
</mat-form-field>
3406
-
3407
- <mat-autocomplete [class]="panelClass" #auto="matAutocomplete" [displayWith]="displayFn"
3408
- [disableRipple]="disableRipple" [aria-label]="ariaLabel" [aria-labelledby]="ariaLabelledby"
3409
- (opened)="openedSpy()" (closed)="closedSpy()">
3410
- <mat-option
3411
- *ngFor="let state of filteredStates"
3412
- [value]="state"
3413
- [style.height.px]="state.height"
3414
- [disabled]="state.disabled">
3415
- <span>{{ state.code }}: {{ state.name }}</span>
3416
- </mat-option>
3417
- </mat-autocomplete>
3418
3439
` ;
3419
3440
3420
3441
@Component ( { template : SIMPLE_AUTOCOMPLETE_TEMPLATE } )
@@ -3431,6 +3452,7 @@ class SimpleAutocomplete implements OnDestroy {
3431
3452
ariaLabel : string ;
3432
3453
ariaLabelledby : string ;
3433
3454
panelClass = 'class-one class-two' ;
3455
+ theme : string ;
3434
3456
openedSpy = jasmine . createSpy ( 'autocomplete opened spy' ) ;
3435
3457
closedSpy = jasmine . createSpy ( 'autocomplete closed spy' ) ;
3436
3458
0 commit comments