fix: set option.selected before dispatching input event for select and combobox - #1187
Open
syrfmy wants to merge 2 commits into
Open
fix: set option.selected before dispatching input event for select and combobox#1187syrfmy wants to merge 2 commits into
syrfmy wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 4d6906c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
syrfmy
force-pushed
the
fix/hidden-option-validation
branch
from
August 7, 2026 06:39
be9442f to
4d6906c
Compare
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.
What is it?
Why is it needed?
Closes #1171
Closes #1186
Currently, in
hidden-select-option.tsxandcombobox-hidden-option.tsx, theinputevent was dispatched before setting theselectedproperty on the<option>. This caused Modular Forms to read stale validation state because the DOM element hadn't updated itsselectedattribute yet when the event fired.Why does this bug only happen when selecting a new option after already having one selected?
If you select the last option directly from an empty state, it works. The bug only manifests when you select an initial option (e.g., Option 0) and then select the last option (Option 4).
Here is why:
useTask$top-down.inputevent, then sets its.selected = false.inputevent first (at this exact moment, Option 0 is false and Option 4 is still false, so the<select>is completely empty!). Modular Forms catches this event, reads the empty DOM state, and updates its internal state to "invalid/empty"..selected = true, but it's too late — Modular Forms' internal state is already stuck on the stale empty read.This PR fixes form validation by:
option.selectedbefore dispatching the input event.Includes new E2E tests for both Select and Combobox that specifically test the "select initial option -> select last option -> submit" flow to ensure this regression never happens again.
(Note: Some pre-existing tests in the suite appear to be flaky and fail intermittently. These failures are unrelated to the changes in this PR.)
Checklist:
pnpm changeand documented my changes