Repository navigation
fix: restore Controller blur validation after reset - #13817
Merged
bluebill1049 merged 2 commits intoOct 2, 2026
Merged
bluebill1049 merged 2 commits into
bluebill1049 merged 2 commits into
Conversation
bluebill1049
approved these changes
Oct 2, 2026
6 tasks done
bluebill1049
added a commit
that referenced
this pull request
Oct 21, 2026
…idates them (#13925) * fix(reset): keep mounted controller fields registered so submit still validates them reset() without keepFieldsRef empties _fields, and a Controller registers again only when it renders. A Controller that does not rerender after the reset (React.memo with an unchanged value, or passed as children) stays on screen unregistered: handleSubmit, trigger() and setFocus() skip it, so a required field is submitted empty. onChange and onBlur already register it again (#13497, #13817); these paths do not go through the Controller. Keep the fields of mounted Controllers whose name is in the reset values, and add them back to the mounted and disabled names after the reset. * test(reset): cover unmount, field arrays and isValid for kept controllers bluebill1049 asked in review whether keeping the mounted Controller registrations is enough without calling updateValidAndValue() again, and for tests on unmounting after reset and on field arrays. The call is still needed. A kept field makes register() skip updateValidAndValue() when the Controller rerenders, so without it a reset that changes the value leaves isValid stale. With shouldUnregister the reset empties _formValues, and the call puts the value back. The new tests check isValid after a reset that changes the value, that a Controller unmounted after reset is not kept by the next reset, and that a reset which removes field array rows keeps none of their names. * refactor(reset): simplify kept controller registration --------- Co-authored-by: maxymlyskov <[email protected]>
This was referenced Nov 11, 2026
Closed
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.
Proposed Changes
Calling
reset(values)can remove a mounted Controller's field registration without rerendering it when the watched value is unchanged. Its next blur then skips validation inonTouchedmode.Register the field again when handling blur if its registration is missing, preserving its current rules, value and disabled option. This follows the existing change handler behavior. Add a regression test with a memoized Controller that does not subscribe to field state.
Fixes #13816
No new dependencies.
Type of change
Checklist:
Validation (author's run, I did not re-run it): the regression test fails on unchanged source (no validate calls) and passes patched. Unit suites: 126 suites, 1486 tests, 26 snapshots passed. Root and type-test TypeScript checks, lint (0 errors, none on changed files), format, build and API extraction passed. Affected Controller, basic validation and reset browser flows passed (9 tests).
Browser caveat: the full browser suite passes 89 tests but the existing
setValueAsyncStrictModetest fails. The same failure reproduces on unchanged source and when run alone. This PR does not change that behavior. Browser checks used the locally installed Chromium executable.