Repository navigation
[field] Sync controlled value changes with field state - #5460
Merged
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,304.84 ms +140.41 ms(+12.1%) | Renders: 76 (+0) | Paint: 2,052.24 ms +211.60 ms(+11.5%)
…and 1 more (+9 within noise) — details Metric alarms
…and 6 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-control-value-sync
branch
from
August 10, 2026 13:33
6a40cf1 to
14d39e5
Compare
atomiks
marked this pull request as ready for review
August 13, 2026 11:23
atomiks
requested review from
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
August 13, 2026 11:23
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.
Field.Controlwas the only Field control that ignored controlled value changes. Switch, Checkbox, Checkbox Group, Radio Group, Select, Slider, Combobox, Number Field, and OTP Field all sync throughuseValueChangedalready.Field.Controlinstead drove every field concern from the DOM change event, so a value set from code had no path at all.Two bugs followed.
Dirty state never cleared for non-string values. The dirty check compares the input's string value against a baseline captured from the
valueprop. Withvalue={5}the baseline was the number5, so"5" !== 5held forever anddata-dirtystayed set even after the user returned the field to its initial value. Array values failed the same way by reference. The control now registers the serialized value, so the baseline and the comparison agree.Programmatic changes left the field stale. Setting the value from code, such as a clear button or a form library reset, updated the input text but not filled, dirty, or validity, so a resolved error stayed visible and a pending async validator for the old value could still publish.
The fix gives each mode one owner instead of running two sync paths at once.
useValueChangedowns the controlled path,onChangeowns the uncontrolled path, andonChangereturns early when controlled.Field.Controlnow has the same shape as its siblings, with the residual difference being the mount-time DOM read that its uncontrolled mode requires.Two smaller fixes ride along:
details.cancel()inonValueChangenow stops the internal handling. It was ignored.Performance
Renders per keystroke for a controlled input, counted in jsdom (mount, then four keystrokes):
onSubmitonChangeMoving the work into a layout effect costs one extra render per keystroke in
onChangemode. That is the cost every sibling control already pays, andField.Controlnow matches Number Field exactly. The base column achieved one render by doing the work synchronously in the change handler, which is the second sync path this PR removes.