Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const MAT_AUTOCOMPLETE_VALUE_ACCESSOR: any = {
'[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',
'[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
'[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
'[attr.aria-haspopup]': '!autocompleteDisabled',
'[attr.aria-haspopup]': 'autocompleteDisabled ? null : "listbox"',
// 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()',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,12 @@ describe('MDC-based MatAutocomplete', () => {
});

it('should set aria-haspopup depending on whether the autocomplete is disabled', () => {
expect(input.getAttribute('aria-haspopup')).toBe('true');
expect(input.getAttribute('aria-haspopup')).toBe('listbox');

fixture.componentInstance.autocompleteDisabled = true;
fixture.detectChanges();

expect(input.getAttribute('aria-haspopup')).toBe('false');
expect(input.hasAttribute('aria-haspopup')).toBe(false);
});

});
Expand Down
2 changes: 1 addition & 1 deletion src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ export abstract class _MatAutocompleteTriggerBase implements ControlValueAccesso
'[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',
'[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
'[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
'[attr.aria-haspopup]': '!autocompleteDisabled',
'[attr.aria-haspopup]': 'autocompleteDisabled ? null : "listbox"',
// 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()',
Expand Down
4 changes: 2 additions & 2 deletions src/material/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,12 @@ describe('MatAutocomplete', () => {
});

it('should set aria-haspopup depending on whether the autocomplete is disabled', () => {
expect(input.getAttribute('aria-haspopup')).toBe('true');
expect(input.getAttribute('aria-haspopup')).toBe('listbox');

fixture.componentInstance.autocompleteDisabled = true;
fixture.detectChanges();

expect(input.getAttribute('aria-haspopup')).toBe('false');
expect(input.hasAttribute('aria-haspopup')).toBe(false);
});

});
Expand Down