[autocomplete] Fix item removal when it receives focus from VoiceOver before using Backspace#48572
Merged
silviuaavram merged 6 commits intoJun 1, 2026
Conversation
Deploy previewhttps://deploy-preview-48572--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 addresses an accessibility-related Autocomplete (multiple) regression where VoiceOver-driven focus/backspace interactions could cause extra chip removals by syncing focused chip state on focus and attempting to suppress a VoiceOver-specific synthetic Backspace.
Changes:
- Add
onFocusto tag/chip props to keepfocusedItemin sync when focus comes from non-keyboard sources (e.g. VoiceOver navigation). - Add a
ignoreNextBackspaceRefmechanism intended to suppress a synthetic Backspace event that VoiceOver dispatches to the input after chip deletion. - Update existing tag-navigation tests to use
user.keyboardand add new tests to validate focused-chip removal behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/mui-material/src/useAutocomplete/useAutocomplete.js | Adds focused chip sync on focus and introduces a ref-based suppression for VoiceOver’s extra Backspace event. |
| packages/mui-material/src/Autocomplete/Autocomplete.test.js | Migrates relevant tests to user.keyboard and adds assertions for removing only the focused chip. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mj12albert
reviewed
May 26, 2026
mj12albert
approved these changes
May 29, 2026
mj12albert
left a comment
Member
There was a problem hiding this comment.
Looks good, tested the fix with VO+Chrome/Safari
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.
When focus on the selected items, in a multiple selection autocomplete, comes from a non native keyboard event, we are not updating the state with the focused item. In the issue case, the focus comes from VoiceOver navigation. Also, VoiceOver is sending another Backspace event on the
inputimmediately after it sent one to theChip.Consequently, instead of deleting the one focused item, we were deleting 3 items: focused one (actually a Chip delete handler), and 2 from the end, one because focusedItem was -1 (not updating according to VoiceOver focus) and one because of the extra
inputbackspace event.Fixes:
inputhappens, exit and restore the ref info. This is not ideal, but I can't figure anything better.Added tests for the focusedItem sync only. The second case, related to VoiceOver sending another Backspace event on top of the Chip one, is impossible to unit test.
Fixes #44936