Repository navigation
fix(ComboBox): don't commit value on blur when isReadOnly - #10850
Closed
florianaltendorfer wants to merge 1 commit into
Closed
florianaltendorfer wants to merge 1 commit into
florianaltendorfer wants to merge 1 commit into
Conversation
Read-only ComboBoxes cannot change their selection or input, so skip committing a value when focus leaves the field. AI-assisted: Claude Code
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.
Closes #10846.
A read-only ComboBox can't change its selection or input, but
useComboBoxStatestill rancommitValue()on blur. When bothvalueandinputValueare controlled and the selected item isn't in the collection (e.g. async items not loaded yet),commitSelectionsees the input text differ from the missing item's text and firesonChange/onSelectionChange, which apps that derive the input text from the selection turn into a cleared field. The blur commit is now skipped whenisReadOnlyis set, the same way the focus handler already skips opening the menu. Keyboard commits were already disabled for read-only, so blur was the only remaining path.✅ Pull Request Checklist:
📝 Test Instructions:
Added a RAC test with a read-only ComboBox whose controlled
valueisn't in the items; focus and blur no longer callonChange/onSelectionChange(the test fails without the fix). Ran the jest ComboBox suites for RAC, react-aria, react-stately, React Spectrum v3 and S2. To check manually, use the repro from the issue: focus then blur the read-only field and the input keeps its text.🧢 Your Project: