[autocomplete] Wrap the no results message in a status element#48690
Open
silviuaavram wants to merge 1 commit into
Open
[autocomplete] Wrap the no results message in a status element#48690silviuaavram wants to merge 1 commit into
silviuaavram wants to merge 1 commit into
Conversation
Deploy previewhttps://deploy-preview-48690--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Autocomplete to improve assistive-technology announcements when there are no matching options by introducing a new noOptions slot that provides a live-region status container around the existing “no options” content.
Changes:
- Add a
noOptionsslot (andslotProps.noOptions) and wrap the no-options content in arole="status"live region (aria-live="polite",aria-atomic="true"). - Extend TypeScript typings (slot + overrides augmentation) and PropTypes to include the new slot.
- Add/adjust tests and regenerate API docs reflecting the new slot.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mui-material/src/Autocomplete/Autocomplete.js | Adds noOptions slot via useSlot and wraps the no-options message in a status live region. |
| packages/mui-material/src/Autocomplete/Autocomplete.d.ts | Adds noOptions to AutocompleteSlots and slot-props typing + overrides interface. |
| packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx | Adds TS coverage for slots.noOptions / slotProps.noOptions usage (including ref). |
| packages/mui-material/src/Autocomplete/Autocomplete.test.js | Adds tests around noOptionsText rendering and the status container behavior. |
| docs/translations/api-docs/autocomplete/autocomplete.json | Updates slot descriptions to include noOptions. |
| docs/pages/material-ui/api/autocomplete.json | Updates API docs output for the new noOptions slot and slotProps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| })), | ||
| ); | ||
|
|
||
| const AutocompleteNoOptionsContainer = styled('div', {})(); |
Comment on lines
+609
to
+620
| const [NoOptionsSlot, noOptionsProps] = useSlot('noOptions', { | ||
| elementType: AutocompleteNoOptionsContainer, | ||
| externalForwardedProps, | ||
| ownerState, | ||
| className: classes.noOptions, | ||
| additionalProps: { | ||
| role: 'status', | ||
| 'aria-live': 'polite', | ||
| 'aria-atomic': 'true', | ||
| }, | ||
| }); | ||
|
|
Member
Author
There was a problem hiding this comment.
This is a good point ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #48666
Add a new
noOptionsslot that wraps the "no options" content with a container element. The container renders withrole="status",aria-live="polite", andaria-atomic="true"so assistive technologies announce the absence of options without requiring the popup to be open.Changes:
AutocompleteNoOptionsContainerstyled element as the default slot elementnoOptionsviauseSlotwith the existingnoOptionsCSS classAutocompleteNoOptionsSlotPropsOverridesaugmentation interfacenoOptionstoAutocompleteSlotsandAutocompleteSlotsAndSlotPropsslotsandslotProps