[field] Validate once on Enter inside a Form - #5459
Merged
atomiks merged 3 commits intoAug 24, 2026
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,093.73 ms +153.35 ms(+16.3%) | Renders: 76 (+0) | Paint: 1,787.40 ms +262.97 ms(+17.3%)
…and 1 more (+9 within noise) — details Metric alarms
…and 4 more metric alarms — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
atomiks
force-pushed
the
claude/field-enter-validation-dedupe
branch
from
August 13, 2026 12:28
da2b88b to
8515301
Compare
atomiks
force-pushed
the
claude/field-enter-validation-dedupe
branch
from
August 13, 2026 12:30
8515301 to
41225fd
Compare
atomiks
marked this pull request as ready for review
August 17, 2026 08:06
atomiks
requested review from
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
August 17, 2026 08:06
atomiks
force-pushed
the
claude/field-enter-validation-dedupe
branch
from
August 24, 2026 08:46
0b28f09 to
a3dc55a
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.
When a
Field.Controlinput sits inside aFormand is natively associated with it, pressing Enter ran the focused field's validator twice. The keydown handler committed validation, and the browser's implicit submission then ranForm's submit handler, which validates every field again. An async or server-side validator on that field fired two requests per keypress, andonValidityChangefired twice.The keydown commit is now deferred by a timeout and skipped when the form submitted in the meantime.
submitAttemptedRefbecomessubmitCountRef(a counter) so each keypress can tell whether a submit happened after it. The deferral only applies when the input is natively associated with the surrounding Base UI form and the keydown was notpreventDefault()-ed; standalone inputs and foreign-form associations still commit synchronously.A plain "skip the commit inside a Form" gate is not enough. Implicit submission does not happen when the default submit button is disabled, or when a keydown listener prevents it, and Enter must still validate the field in those cases. The timeout fallback covers them.
Notes
Formis now asynchronous. Tests that assert synchronously after an Enter keydown need to await a tick.FieldValidity.test.tsxassertion change (validator count 1 → 2 inonSubmitmode) is correct rather than a regression. A real submit bumps the submit count, andonSubmitmode re-validates on change after a submit attempt. The old count of 1 relied on the keydown loophole never registering the attempt.@base-ui/react/inputgrows by ~198 B gzipped, mostly theTimeoutclass entering a bundle that previously had none. Alongside any other Base UI import that already shipsTimeout(field, select, tooltip, toast, …), the marginal cost is ~50 B.