@@ -749,6 +749,8 @@ describe('MatChipList', () => {
749749 let nativeChips : HTMLElement [ ] ;
750750
751751 describe ( 'single selection' , ( ) => {
752+ let chipListEl : HTMLElement ;
753+
752754 beforeEach ( ( ) => {
753755 fixture = createComponent ( BasicChipList ) ;
754756 fixture . detectChanges ( ) ;
@@ -757,6 +759,7 @@ describe('MatChipList', () => {
757759 . queryAll ( By . css ( 'mat-chip' ) )
758760 . map ( chip => chip . nativeElement ) ;
759761 chips = fixture . componentInstance . chips ;
762+ chipListEl = fixture . debugElement . query ( By . css ( 'mat-chip-list' ) ) ! . nativeElement ;
760763 } ) ;
761764
762765 it ( 'should take an initial view value with reactive forms' , ( ) => {
@@ -949,6 +952,22 @@ describe('MatChipList', () => {
949952
950953 expect ( formField . classList ) . not . toContain ( 'mat-focused' ) ;
951954 } ) ) ;
955+
956+ it ( 'should set `aria-describedby` to the id of the mat-hint' , fakeAsync ( ( ) => {
957+ expect ( chipListEl . getAttribute ( 'aria-describedby' ) ) . toBeNull ( ) ;
958+
959+ fixture . componentInstance . hint = 'test' ;
960+ fixture . detectChanges ( ) ;
961+ const hint = fixture . debugElement . query ( By . css ( '.mat-hint' ) ) . nativeElement ;
962+ expect ( chipListEl . getAttribute ( 'aria-describedby' ) ) . toBe ( hint . getAttribute ( 'id' ) ) ;
963+ expect ( chipListEl . getAttribute ( 'aria-describedby' ) ) . toMatch ( / ^ m a t - h i n t - \d + $ / ) ;
964+ } ) ) ;
965+
966+ it ( 'should support user binding to `aria-describedby`' , fakeAsync ( ( ) => {
967+ fixture . componentInstance . ariaDescribedBy = 'test' ;
968+ fixture . detectChanges ( ) ;
969+ expect ( chipListEl . getAttribute ( 'aria-describedby' ) ) . toBe ( 'test' ) ;
970+ } ) ) ;
952971 } ) ;
953972
954973 describe ( 'multiple selection' , ( ) => {
@@ -1586,11 +1605,13 @@ class FormFieldChipList {
15861605 template : `
15871606 <mat-form-field>
15881607 <mat-chip-list placeholder="Food" [formControl]="control"
1608+ [aria-describedby]="ariaDescribedBy"
15891609 [tabIndex]="tabIndexOverride" [selectable]="selectable">
15901610 <mat-chip *ngFor="let food of foods" [value]="food.value" [disabled]="food.disabled">
15911611 {{ food.viewValue }}
15921612 </mat-chip>
15931613 </mat-chip-list>
1614+ <mat-hint *ngIf="hint">{{ hint }}</mat-hint>
15941615 </mat-form-field>
15951616 ` ,
15961617} )
@@ -1605,7 +1626,9 @@ class BasicChipList {
16051626 { value : 'pasta-6' , viewValue : 'Pasta' } ,
16061627 { value : 'sushi-7' , viewValue : 'Sushi' } ,
16071628 ] ;
1629+ ariaDescribedBy : string = '' ;
16081630 control = new FormControl < string | null > ( null ) ;
1631+ hint : string ;
16091632 tabIndexOverride : number ;
16101633 selectable : boolean ;
16111634
0 commit comments