Skip to content

fix(unregister): clear descendant registrations when removing a parent - #13976

Merged
bluebill1049 merged 1 commit into
react-hook-form:masterfrom
charan-rathore:fix/unregister-parent-disabled-descendants
Nov 1, 2026
Merged

bluebill1049 merged 1 commit into
react-hook-form:masterfrom
charan-rathore:fix/unregister-parent-disabled-descendants

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Proposed Changes

unregister('parent', { keepValue: true }) removes a nested input's field data, but only deletes the literal parent name from the registration sets. If parent.child was disabled, its stale disabled entry makes the next submit silently strip the child value that keepValue retained.

Include mounted descendants when clearing a named registration. Match the dot boundary so unregistering parent does not clear parentOther. Keep no-name unregister on its existing whole-form path.

This extends the direct-field contract from #13703 to parent paths. No public API, dependency or workflow changes. No linked issue.

Type of change

  • Bug fix

Checklist

  • Code follows project style
  • Reviewed the focused diff
  • No new warnings in changed files
  • Added regression tests and checked source-only fail-before
  • Unit tests pass locally; browser caveat below

Validation

Current master 26ba0d3, Node 22.23.4:

  • Five new cases cover a rendered disabled input hidden via parent unregister, nested/array descendants, similarly prefixed siblings, and stopping removed-child validation. Unchanged source: 4 fail, 1 passes. Patched unregister suites: 34 pass.
  • A separately bundled real Chrome form confirms the submit payload. Before: only the sibling survives. After: the retained parent.child and sibling are both submitted. Base and candidate used separately built bundles, not a shared Vite cache.
  • Full Jest: 132 suites, 1,815 tests, 26 snapshots pass.
  • Root/type-test TypeScript, builds, export assertions, API extraction and changed-file lint/format pass. Full lint has 0 errors and 572 existing warnings. API Extractor keeps its compiler-version advisory.
  • Browser suite, complete two-worker shards: 89 pass, 1 fails (setValueAsyncStrictMode). That exact test also fails 3/3 with the unchanged implementation. This is not an all-green browser-suite claim. Earlier unsharded attempts timed out; a four-worker attempt had additional timeouts, so the complete two-worker runs are reported here.
  • Normal pre-commit checks pass.

Prepared with AI assistance. Local tests do not claim maintainer approval or merge.

@bluebill1049
bluebill1049 merged commit c75b842 into react-hook-form:master Nov 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants