File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ export abstract class MatFormFieldControl<T> {
7575 */
7676 readonly disableAutomaticLabeling ?: boolean ;
7777
78+ readonly describedByIds ?: string [ ] ;
79+
7880 /** Sets the list of element IDs that currently describe this control. */
7981 abstract setDescribedByIds ( ids : string [ ] ) : void ;
8082
Original file line number Diff line number Diff line change @@ -308,6 +308,9 @@ export class MatFormField
308308 // Unique id for the hint label.
309309 readonly _hintLabelId = this . _idGenerator . getId ( 'mat-mdc-hint-' ) ;
310310
311+ // Ids obtained from the fields
312+ private _describedByIds : Array < String > = [ ] ;
313+
311314 /** Gets the current form field control */
312315 get _control ( ) : MatFormFieldControl < any > {
313316 return this . _explicitFormFieldControl || this . _formFieldControl ;
@@ -705,7 +708,17 @@ export class MatFormField
705708 ids . push ( ...this . _errorChildren . map ( error => error . id ) ) ;
706709 }
707710
708- this . _control . setDescribedByIds ( ids ) ;
711+ let currentIds = this . _control . describedByIds ?? [ ] ;
712+ let combinedIds : Array < string > = [ ] ;
713+ currentIds . forEach ( id => {
714+ if ( ! this . _describedByIds . includes ( id ) ) {
715+ combinedIds . push ( id ) ;
716+ }
717+ } ) ;
718+ combinedIds . concat ( ...ids ) ;
719+
720+ this . _control . setDescribedByIds ( combinedIds ) ;
721+ this . _describedByIds = ids ;
709722 }
710723 }
711724
You can’t perform that action at this time.
0 commit comments