mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
mmalerba
parent
e67fd7b84d
commit
f0a0ab109e
@@ -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()',
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user