Skip to content

Commit 82cf66f

Browse files
committed
wip
1 parent 56c5c0f commit 82cf66f

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

Diff for: src/material-experimental/mdc-select/select.html

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
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+
-->
110
<div cdk-overlay-origin
11+
[attr.aria-owns]="panelOpen ? id + '-panel' : null"
212
class="mat-mdc-select-trigger"
313
(click)="toggle()"
414
#fallbackOverlayOrigin="cdkOverlayOrigin"

Diff for: src/material-experimental/mdc-select/select.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,17 @@ describe('MDC-based MatSelect', () => {
196196
expect(ariaControls).toBe(document.querySelector('.mat-mdc-select-panel')!.id);
197197
}));
198198

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);
201202

202203
fixture.componentInstance.select.open();
203204
fixture.detectChanges();
204205
flush();
205206

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);
209210
}));
210211

211212
it('should set aria-expanded based on the select open state', fakeAsync(() => {

Diff for: src/material-experimental/mdc-select/select.ts

-7
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ export class MatSelectTrigger {}
6262
'class': 'mat-mdc-select',
6363
'[attr.id]': 'id',
6464
'[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',
7265
'[attr.aria-controls]': 'panelOpen ? id + "-panel" : null',
7366
'[attr.aria-expanded]': 'panelOpen',
7467
'[attr.aria-label]': 'ariaLabel || null',

Diff for: src/material/select/select.html

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
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+
-->
110
<div cdk-overlay-origin
11+
[attr.aria-owns]="panelOpen ? id + '-panel' : null"
212
class="mat-select-trigger"
313
(click)="toggle()"
414
#origin="cdkOverlayOrigin"

Diff for: src/material/select/select.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,17 @@ describe('MatSelect', () => {
165165
expect(ariaControls).toBe(document.querySelector('.mat-select-panel')!.id);
166166
}));
167167

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);
170171

171172
fixture.componentInstance.select.open();
172173
fixture.detectChanges();
173174
flush();
174175

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);
178179
}));
179180

180181
it('should set aria-expanded based on the select open state', fakeAsync(() => {

Diff for: src/material/select/select.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1111,13 +1111,6 @@ export abstract class _MatSelectBase<C> extends _MatSelectMixinBase implements A
11111111
'class': 'mat-select',
11121112
'[attr.id]': 'id',
11131113
'[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',
11211114
'[attr.aria-controls]': 'panelOpen ? id + "-panel" : null',
11221115
'[attr.aria-expanded]': 'panelOpen',
11231116
'[attr.aria-label]': 'ariaLabel || null',

0 commit comments

Comments
 (0)