@@ -30,6 +30,7 @@ import {
3030 NgForm ,
3131 Validators ,
3232} from '@angular/forms' ;
33+ import { FORM_FIELD } from '@angular/forms/signals' ;
3334import { _ErrorStateTracker , ErrorStateMatcher } from '../core' ;
3435import { MatFormFieldControl } from '../form-field' ;
3536import { merge , Observable , Subject } from 'rxjs' ;
@@ -258,14 +259,15 @@ export class MatChipGrid
258259 const parentForm = inject ( NgForm , { optional : true } ) ;
259260 const parentFormGroup = inject ( FormGroupDirective , { optional : true } ) ;
260261 const defaultErrorStateMatcher = inject ( ErrorStateMatcher ) ;
262+ const formField = inject ( FORM_FIELD , { optional : true , self : true } ) ;
261263
262264 if ( this . ngControl ) {
263265 this . ngControl . valueAccessor = this ;
264266 }
265267
266268 this . _errorStateTracker = new _ErrorStateTracker (
267269 defaultErrorStateMatcher ,
268- this . ngControl ,
270+ formField || this . ngControl ,
269271 parentFormGroup ,
270272 parentForm ,
271273 this . stateChanges ,
@@ -492,7 +494,7 @@ export class MatChipGrid
492494 this . stateChanges . next ( ) ;
493495 }
494496
495- protected override _redirectDestroyedChipFocus ( ) {
497+ protected override _redirectDestroyedChipFocus ( ) {
496498 if ( this . _lastDestroyedFocusedChipIndex === null ) {
497499 return ;
498500 }
@@ -501,8 +503,7 @@ export class MatChipGrid
501503
502504 // If there are no chips left, or the set focuses the input,
503505 // clear the active item silently to prevent stale references.
504- if ( ! this . _chips . length ||
505- ( this . _chips . length === 1 && this . _chips . first . disabled ) ) {
506+ if ( ! this . _chips . length || ( this . _chips . length === 1 && this . _chips . first . disabled ) ) {
506507 this . _keyManager . updateActiveItem ( - 1 ) ;
507508 }
508509 }
0 commit comments