[field] Fix stale filled and focused state on control replacement - #5345
Draft
atomiks wants to merge 1 commit into
Draft
[field] Fix stale filled and focused state on control replacement#5345atomiks wants to merge 1 commit into
atomiks wants to merge 1 commit into
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,250.90 ms +99.64 ms(+8.7%) | Renders: 78 (+0) | Paint: 1,976.31 ms +176.62 ms(+9.8%)
11 tests within noise — details Metric alarms
…and 1 more metric alarm — 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-lifecycle-audit-fixes-73dada
branch
from
July 27, 2026 05:35
9ba0306 to
4354b0e
Compare
atomiks
force-pushed
the
claude/field-lifecycle-audit-fixes-73dada
branch
from
July 27, 2026 05:35
4354b0e to
69c0549
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.
Two Field lifecycle states could go stale across control replacement. A filled uncontrolled control replaced by a fresh empty one under the same
Field.Rootkeptdata-filledset, and a control removed while focused never fires blur, leavingdata-focusedstuck on the root.fillednow follows last-attach-wins ownership of the shared input ref: the owning control publishes unconditionally on attach, a superseded control can't clear its successor's state, and a survivor reclaims a null ref after the owner unmounts. Each control also tracks whether it holds the field's focused state and releases it on unmount only in that case. Form registration reads the control's own element rather than the mutable shared ref, so field values stay readable when overlapping control lifetimes clear that ref.Native label association is deliberately left on the existing commit-driven lifecycle (tests now pin it, including labels in other containers,
htmlForretargeting, and OTP slots mounting late). Label changes with no control rerender at all remain untracked in v1:useAriaLabelledBypatches over the hidden-input-inside-label layout, which is slated for rework in v2, and observer-based tracking measurably regressed mount performance for what it covered.