File tree 2 files changed +17
-1
lines changed 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1657,6 +1657,22 @@ describe('MatSelect', () => {
1657
1657
. toContain ( options [ 1 ] . id , `Expected aria-owns to contain IDs of its child options.` ) ;
1658
1658
} ) ) ;
1659
1659
1660
+ it ( 'should remove aria-owns when the options are not visible' , fakeAsync ( ( ) => {
1661
+ const select = fixture . debugElement . query ( By . css ( 'mat-select' ) ) ;
1662
+
1663
+ expect ( select . nativeElement . hasAttribute ( 'aria-owns' ) )
1664
+ . toBe ( true , 'Expected select to have aria-owns while open.' ) ;
1665
+
1666
+ const backdrop =
1667
+ overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
1668
+ backdrop . click ( ) ;
1669
+ fixture . detectChanges ( ) ;
1670
+ flush ( ) ;
1671
+
1672
+ expect ( select . nativeElement . hasAttribute ( 'aria-owns' ) )
1673
+ . toBe ( false , 'Expected select not to have aria-owns when closed.' ) ;
1674
+ } ) ) ;
1675
+
1660
1676
it ( 'should set the option id properly' , fakeAsync ( ( ) => {
1661
1677
let firstOptionID = options [ 0 ] . id ;
1662
1678
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ export class MatSelectTrigger {}
188
188
'[attr.aria-required]' : 'required.toString()' ,
189
189
'[attr.aria-disabled]' : 'disabled.toString()' ,
190
190
'[attr.aria-invalid]' : 'errorState' ,
191
- '[attr.aria-owns]' : '_optionIds' ,
191
+ '[attr.aria-owns]' : 'panelOpen ? _optionIds : null ' ,
192
192
'[attr.aria-multiselectable]' : 'multiple' ,
193
193
'[attr.aria-describedby]' : '_ariaDescribedby || null' ,
194
194
'[attr.aria-activedescendant]' : '_getAriaActiveDescendant()' ,
You can’t perform that action at this time.
0 commit comments