File tree 6 files changed +32
-24
lines changed
material-experimental/mdc-select
6 files changed +32
-24
lines changed Original file line number Diff line number Diff line change
1
+ <!--
2
+ Note that the select trigger element specifies `aria-owns` pointing to the listbox overlay.
3
+ While aria-owns is not required for the ARIA 1.2 `role="combobox"` interaction pattern,
4
+ it fixes an issue with VoiceOver when the select appears inside of an `aria-model="true"`
5
+ element (e.g. a dialog). Without this `aria-owns`, the `aria-modal` on a dialog prevents
6
+ VoiceOver from "seeing" the select's listbox overlay for aria-activedescendant.
7
+ Using `aria-owns` re-parents the select overlay so that it works again.
8
+ See https://github.com/angular/components/issues/20694
9
+ -->
1
10
< div cdk-overlay-origin
11
+ [attr.aria-owns] ="panelOpen ? id + '-panel' : null "
2
12
class ="mat-mdc-select-trigger "
3
13
(click) ="toggle() "
4
14
#fallbackOverlayOrigin ="cdkOverlayOrigin "
Original file line number Diff line number Diff line change @@ -196,16 +196,17 @@ describe('MDC-based MatSelect', () => {
196
196
expect ( ariaControls ) . toBe ( document . querySelector ( '.mat-mdc-select-panel' ) ! . id ) ;
197
197
} ) ) ;
198
198
199
- it ( 'should point the aria-owns attribute to the listbox' , fakeAsync ( ( ) => {
200
- expect ( select . hasAttribute ( 'aria-owns' ) ) . toBe ( false ) ;
199
+ it ( 'should point the aria-owns attribute to the listbox on the trigger' , fakeAsync ( ( ) => {
200
+ const trigger = select . querySelector ( '.mat-mdc-select-trigger' ) ! ;
201
+ expect ( trigger . hasAttribute ( 'aria-owns' ) ) . toBe ( false ) ;
201
202
202
203
fixture . componentInstance . select . open ( ) ;
203
204
fixture . detectChanges ( ) ;
204
205
flush ( ) ;
205
206
206
- const ariaControls = select . getAttribute ( 'aria-owns' ) ;
207
- expect ( ariaControls ) . toBeTruthy ( ) ;
208
- expect ( ariaControls ) . toBe ( document . querySelector ( '.mat-mdc-select-panel' ) ! . id ) ;
207
+ const ariaOwns = trigger . getAttribute ( 'aria-owns' ) ;
208
+ expect ( ariaOwns ) . toBeTruthy ( ) ;
209
+ expect ( ariaOwns ) . toBe ( document . querySelector ( '.mat-mdc-select-panel' ) ! . id ) ;
209
210
} ) ) ;
210
211
211
212
it ( 'should set aria-expanded based on the select open state' , fakeAsync ( ( ) => {
Original file line number Diff line number Diff line change @@ -62,13 +62,6 @@ export class MatSelectTrigger {}
62
62
'class' : 'mat-mdc-select' ,
63
63
'[attr.id]' : 'id' ,
64
64
'[attr.tabindex]' : 'tabIndex' ,
65
- // While aria-owns is not required for the `role="combobox"` interaction pattern,
66
- // it fixes an issue with VoiceOver when the select appears inside of an `aria-model="true"`
67
- // element (e.g. a dialog). Without `aria-owns`, the `aria-modal` on a dialog would prevent
68
- // VoiceOver from "seeing" the select's listbox overlay for aria-activedescendant.
69
- // Using `aria-owns` re-parents the select overlay so that it works again.
70
- // See https://github.com/angular/components/issues/20694
71
- '[attr.aria-owns]' : 'panelOpen ? id + "-panel" : null' ,
72
65
'[attr.aria-controls]' : 'panelOpen ? id + "-panel" : null' ,
73
66
'[attr.aria-expanded]' : 'panelOpen' ,
74
67
'[attr.aria-label]' : 'ariaLabel || null' ,
Original file line number Diff line number Diff line change
1
+ <!--
2
+ Note that the select trigger element specifies `aria-owns` pointing to the listbox overlay.
3
+ While aria-owns is not required for the ARIA 1.2 `role="combobox"` interaction pattern,
4
+ it fixes an issue with VoiceOver when the select appears inside of an `aria-model="true"`
5
+ element (e.g. a dialog). Without this `aria-owns`, the `aria-modal` on a dialog prevents
6
+ VoiceOver from "seeing" the select's listbox overlay for aria-activedescendant.
7
+ Using `aria-owns` re-parents the select overlay so that it works again.
8
+ See https://github.com/angular/components/issues/20694
9
+ -->
1
10
< div cdk-overlay-origin
11
+ [attr.aria-owns] ="panelOpen ? id + '-panel' : null "
2
12
class ="mat-select-trigger "
3
13
(click) ="toggle() "
4
14
#origin ="cdkOverlayOrigin "
Original file line number Diff line number Diff line change @@ -165,16 +165,17 @@ describe('MatSelect', () => {
165
165
expect ( ariaControls ) . toBe ( document . querySelector ( '.mat-select-panel' ) ! . id ) ;
166
166
} ) ) ;
167
167
168
- it ( 'should point the aria-controls attribute to the listbox' , fakeAsync ( ( ) => {
169
- expect ( select . hasAttribute ( 'aria-owns' ) ) . toBe ( false ) ;
168
+ it ( 'should point the aria-owns attribute to the listbox on the trigger' , fakeAsync ( ( ) => {
169
+ const trigger = select . querySelector ( '.mat-select-trigger' ) ! ;
170
+ expect ( trigger . hasAttribute ( 'aria-owns' ) ) . toBe ( false ) ;
170
171
171
172
fixture . componentInstance . select . open ( ) ;
172
173
fixture . detectChanges ( ) ;
173
174
flush ( ) ;
174
175
175
- const ariaControls = select . getAttribute ( 'aria-owns' ) ;
176
- expect ( ariaControls ) . toBeTruthy ( ) ;
177
- expect ( ariaControls ) . toBe ( document . querySelector ( '.mat-select-panel' ) ! . id ) ;
176
+ const ariaOwns = trigger . getAttribute ( 'aria-owns' ) ;
177
+ expect ( ariaOwns ) . toBeTruthy ( ) ;
178
+ expect ( ariaOwns ) . toBe ( document . querySelector ( '.mat-select-panel' ) ! . id ) ;
178
179
} ) ) ;
179
180
180
181
it ( 'should set aria-expanded based on the select open state' , fakeAsync ( ( ) => {
Original file line number Diff line number Diff line change @@ -1111,13 +1111,6 @@ export abstract class _MatSelectBase<C> extends _MatSelectMixinBase implements A
1111
1111
'class' : 'mat-select' ,
1112
1112
'[attr.id]' : 'id' ,
1113
1113
'[attr.tabindex]' : 'tabIndex' ,
1114
- // While aria-owns is not required for the `role="combobox"` interaction pattern,
1115
- // it fixes an issue with VoiceOver when the select appears inside of an `aria-model="true"`
1116
- // element (e.g. a dialog). Without `aria-owns`, the `aria-modal` on a dialog would prevent
1117
- // VoiceOver from "seeing" the select's listbox overlay for aria-activedescendant.
1118
- // Using `aria-owns` re-parents the select overlay so that it works again.
1119
- // See https://github.com/angular/components/issues/20694
1120
- '[attr.aria-owns]' : 'panelOpen ? id + "-panel" : null' ,
1121
1114
'[attr.aria-controls]' : 'panelOpen ? id + "-panel" : null' ,
1122
1115
'[attr.aria-expanded]' : 'panelOpen' ,
1123
1116
'[attr.aria-label]' : 'ariaLabel || null' ,
You can’t perform that action at this time.
0 commit comments