fix(autocomplete): remove aria-owns attribute while closed (#12333)

Removes the `aria-owns` attribute from the autocomplete trigger while the panel is closed.

Fixes #12332.
This commit is contained in:
Kristiyan Kostadinov
2018-07-24 22:29:00 +02:00
committed by mmalerba
parent e67fd7b84d
commit f0a0ab109e
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ export function getMatAutocompleteMissingPanelError(): Error {
'[attr.aria-autocomplete]': 'autocompleteDisabled ? null : "list"',
'[attr.aria-activedescendant]': 'activeOption?.id',
'[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
'[attr.aria-owns]': 'autocompleteDisabled ? null : autocomplete?.id',
'[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
// Note: we use `focusin`, as opposed to `focus`, in order to open the panel
// a little earlier. This avoids issues where IE delays the focusing of the input.
'(focusin)': '_handleFocus()',
+10 -1
View File
@@ -1329,7 +1329,16 @@ describe('MatAutocomplete', () => {
const panel = fixture.debugElement.query(By.css('.mat-autocomplete-panel')).nativeElement;
expect(input.getAttribute('aria-owns'))
.toEqual(panel.getAttribute('id'), 'Expected aria-owns to match attached autocomplete.');
.toBe(panel.getAttribute('id'), 'Expected aria-owns to match attached autocomplete.');
});
it('should not set aria-owns while the autocomplete is closed', () => {
expect(input.getAttribute('aria-owns')).toBeFalsy();
fixture.componentInstance.trigger.openPanel();
fixture.detectChanges();
expect(input.getAttribute('aria-owns')).toBeTruthy();
});
it('should restore focus to the input when clicking to select a value', fakeAsync(() => {