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

[Autocomplete] Have the screen reader announce when autocomplete is open and closed #30601

Merged
merged 2 commits into from
Mar 4, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -999,8 +999,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 @@ -1022,12 +1020,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 @@ -288,7 +288,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