@@ -732,7 +732,7 @@ describe('MDC-based MatChipGrid', () => {
732
732
. withContext ( `Expected placeholder not to have an asterisk, as control was not required.` )
733
733
. toBeNull ( ) ;
734
734
735
- fixture . componentInstance . isRequired = true ;
735
+ fixture . componentInstance . chipGrid . required = true ;
736
736
fixture . detectChanges ( ) ;
737
737
738
738
requiredMarker = fixture . debugElement . query ( By . css ( '.mdc-floating-label--required' ) ) ! ;
@@ -741,6 +741,15 @@ describe('MDC-based MatChipGrid', () => {
741
741
. toBeNull ( ) ;
742
742
} ) ;
743
743
744
+ it ( 'should mark the component as required if the control has a required validator' , ( ) => {
745
+ fixture . destroy ( ) ;
746
+ fixture = TestBed . createComponent ( InputChipGrid ) ;
747
+ fixture . componentInstance . control = new FormControl ( undefined , [ Validators . required ] ) ;
748
+ fixture . detectChanges ( ) ;
749
+
750
+ expect ( fixture . nativeElement . querySelector ( '.mdc-floating-label--required' ) ) . toBeTruthy ( ) ;
751
+ } ) ;
752
+
744
753
it ( 'should blur the form field when the active chip is blurred' , fakeAsync ( ( ) => {
745
754
const formField : HTMLElement = fixture . nativeElement . querySelector ( '.mat-mdc-form-field' ) ;
746
755
@@ -1077,8 +1086,7 @@ class FormFieldChipGrid {
1077
1086
template : `
1078
1087
<mat-form-field>
1079
1088
<mat-label>New food...</mat-label>
1080
- <mat-chip-grid #chipGrid
1081
- placeholder="Food" [formControl]="control" [required]="isRequired">
1089
+ <mat-chip-grid #chipGrid placeholder="Food" [formControl]="control">
1082
1090
<mat-chip-row *ngFor="let food of foods" [value]="food.value" (removed)="remove(food)">
1083
1091
{{ food.viewValue }}
1084
1092
</mat-chip-row>
@@ -1106,7 +1114,6 @@ class InputChipGrid {
1106
1114
1107
1115
separatorKeyCodes = [ ENTER , SPACE ] ;
1108
1116
addOnBlur : boolean = true ;
1109
- isRequired : boolean ;
1110
1117
1111
1118
add ( event : MatChipInputEvent ) : void {
1112
1119
const value = ( event . value || '' ) . trim ( ) ;
0 commit comments