Skip to content

Commit

Permalink
[Autocomplete] Have the screen reader announce when autocomplete is o…
Browse files Browse the repository at this point in the history
…pen and closed (#30601)
  • Loading branch information
EdmundMai committed Mar 4, 2022
1 parent fce921a commit 298627c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 84 deletions.
4 changes: 2 additions & 2 deletions packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,6 @@ export default function useAutocomplete(props) {
return {
getRootProps: (other = {}) => ({
'aria-owns': listboxAvailable ? `${id}-listbox` : null,
role: 'combobox',
'aria-expanded': listboxAvailable,
...other,
onKeyDown: handleKeyDown(other),
onMouseDown: handleMouseDown,
Expand All @@ -1034,12 +1032,14 @@ export default function useAutocomplete(props) {
'aria-activedescendant': popupOpen ? '' : null,
'aria-autocomplete': autoComplete ? 'both' : 'list',
'aria-controls': listboxAvailable ? `${id}-listbox` : undefined,
'aria-expanded': listboxAvailable,
// Disable browser's suggestion that might overlap with the popup.
// Handle autocomplete but not autofill.
autoComplete: 'off',
ref: inputRef,
autoCapitalize: 'none',
spellCheck: 'false',
role: 'combobox',
}),
getClearProps: () => ({
tabIndex: -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ describe('useAutocomplete', () => {
return <input {...getInputProps()} />;
};
render(<Test options={['foo', 'bar']} />);
const input = screen.getByRole('textbox');
const input = screen.getByRole('combobox');

act(() => {
fireEvent.change(input, { target: { value: 'free' } });
Expand Down

0 comments on commit 298627c

Please sign in to comment.