File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1739,6 +1739,22 @@ describe('MatSelect', () => {
17391739 . toContain ( options [ 1 ] . id , `Expected aria-owns to contain IDs of its child options.` ) ;
17401740 } ) ) ;
17411741
1742+ it ( 'should remove aria-owns when the options are not visible' , fakeAsync ( ( ) => {
1743+ const select = fixture . debugElement . query ( By . css ( 'mat-select' ) ) ;
1744+
1745+ expect ( select . nativeElement . hasAttribute ( 'aria-owns' ) )
1746+ . toBe ( true , 'Expected select to have aria-owns while open.' ) ;
1747+
1748+ const backdrop =
1749+ overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
1750+ backdrop . click ( ) ;
1751+ fixture . detectChanges ( ) ;
1752+ flush ( ) ;
1753+
1754+ expect ( select . nativeElement . hasAttribute ( 'aria-owns' ) )
1755+ . toBe ( false , 'Expected select not to have aria-owns when closed.' ) ;
1756+ } ) ) ;
1757+
17421758 it ( 'should set the option id properly' , fakeAsync ( ( ) => {
17431759 let firstOptionID = options [ 0 ] . id ;
17441760
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ export class MatSelectTrigger {}
188188 '[attr.aria-required]' : 'required.toString()' ,
189189 '[attr.aria-disabled]' : 'disabled.toString()' ,
190190 '[attr.aria-invalid]' : 'errorState' ,
191- '[attr.aria-owns]' : '_optionIds' ,
191+ '[attr.aria-owns]' : 'panelOpen ? _optionIds : null ' ,
192192 '[attr.aria-multiselectable]' : 'multiple' ,
193193 '[attr.aria-describedby]' : '_ariaDescribedby || null' ,
194194 '[attr.aria-activedescendant]' : '_getAriaActiveDescendant()' ,
You can’t perform that action at this time.
0 commit comments