Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select): remove aria-owns when options aren't in the DOM #9091

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,22 @@ describe('MatSelect', () => {
.toContain(options[1].id, `Expected aria-owns to contain IDs of its child options.`);
}));

it('should remove aria-owns when the options are not visible', fakeAsync(() => {
const select = fixture.debugElement.query(By.css('mat-select'));

expect(select.nativeElement.hasAttribute('aria-owns'))
.toBe(true, 'Expected select to have aria-owns while open.');

const backdrop =
overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement;
backdrop.click();
fixture.detectChanges();
flush();

expect(select.nativeElement.hasAttribute('aria-owns'))
.toBe(false, 'Expected select not to have aria-owns when closed.');
}));

it('should set the option id properly', fakeAsync(() => {
let firstOptionID = options[0].id;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class MatSelectTrigger {}
'[attr.aria-required]': 'required.toString()',
'[attr.aria-disabled]': 'disabled.toString()',
'[attr.aria-invalid]': 'errorState',
'[attr.aria-owns]': '_optionIds',
'[attr.aria-owns]': 'panelOpen ? _optionIds : null',
'[attr.aria-multiselectable]': 'multiple',
'[attr.aria-describedby]': '_ariaDescribedby || null',
'[attr.aria-activedescendant]': '_getAriaActiveDescendant()',
Expand Down