Repository navigation
Fix AutocompleteInput clearing mouse selections on blur - #11364
Merged
fzaninotto merged 2 commits intoSep 9, 2026
Merged
fzaninotto merged 2 commits into
fzaninotto merged 2 commits into
Conversation
fzaninotto
requested changes
Sep 8, 2026
|
|
||
| describe('onCreate', () => { | ||
| it('should keep a clicked choice on blur when autoSelect is enabled', async () => { | ||
| render(<OnCreate autoSelect autoHighlight />); |
Member
There was a problem hiding this comment.
Could you please extract that into its own Story, so that it's testable by hand? It would also help reproduce the issue.
Contributor
Author
There was a problem hiding this comment.
Done — I added a dedicated OnCreateWithAutoSelect Story and updated the regression test to render that Story. This keeps the scenario manually reproducible in Storybook. Local validation: the focused suite passes (75/75), ESLint and Prettier pass, and the root yarn typecheck build completes for all 20 projects.
fzaninotto
approved these changes
Sep 9, 2026
Member
|
Thanks! |
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.
Problem
Fixes #9813.
When
AutocompleteInputuses bothonCreateandautoSelect, clicking an existing choice and then blurring the input clears the selection. MUI emits the selected label again as a free-solo string during blur, and the string has no choice id.Solution
Ignore that duplicate blur change only when its string already matches the selected choice. Unmatched free-solo values and normal choice changes keep their existing behavior.
How To Test
corepack yarn jest packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx --runInBand— 75 tests passedcorepack yarn eslint packages/ra-ui-materialui/src/input/AutocompleteInput.tsx packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx— passed./node_modules/.bin/prettier --config ./.prettierrc.js --check packages/ra-ui-materialui/src/input/AutocompleteInput.tsx packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx— passedcorepack yarn workspace ra-ui-materialui build— passedAdditional Checks
masterfor a bugfixOnCreatestory