Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): revalidate nested fields on parent setFieldValue #2208

Openhemraj-007(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2208/headopened

Revalidate mounted nested fields when a parent object updates via setFieldValue, clearing stale child validation errors. Adds regression test and changeset. Fixes #2113.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where nested fields were not being revalidated when parent object field values were updated through setFieldValue. This fix ensures all mounted nested fields properly revalidate when parent objects change, maintaining consistent validation behavior across all form libraries.
    1. Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 9f53c3db-406f-4677-beb1-826a30255609

      📥 Commits

      Reviewing files that changed from the base of the PR and between 6a73479f2c2659550a6c8b456e3e139bf0d2142e and 8b4eb09d6a03c6945017d4c91aca639685417b71.

      📒 Files selected for processing (4)
      • .changeset/nested-field-revalidate.md
      • packages/form-core/CHANGELOG.md
      • packages/form-core/src/FormApi.ts
      • packages/form-core/tests/FormApi.spec.ts

      📝 Walkthrough

      Walkthrough

      This PR fixes issue #2113 by adding group-aware revalidation of nested mounted fields when a parent object field is updated via setFieldValue. The implementation validates all nested group-member fields, a regression test confirms the fix, and release metadata documents patch version bumps across all form packages.

      Changes

      Nested Field Revalidation Fix

      Layer / File(s)Summary
      Revalidation logic and regression test
      packages/form-core/src/FormApi.ts, packages/form-core/tests/FormApi.spec.ts
      setFieldValue now validates all mounted nested fields belonging to the updated field's group after value changes. Regression test verifies error clearing when parent field transitions from invalid to valid state.
      Release documentation
      .changeset/nested-field-revalidate.md, packages/form-core/CHANGELOG.md
      Changeset and CHANGELOG entry document patch release across all @tanstack/*-form packages with the nested field revalidation fix for issue #2113.

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~12 minutes

      Suggested reviewers

      • crutchcorn

      Poem

      🐰 A parent field updates with grace, Its nested children now keep pace, Validation triggers, errors fade, The form once broken, now remade! ✨

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe PR description is minimal but captures the core change. However, it does not follow the provided template structure with required sections like 'Changes', 'Checklist', and 'Release Impact'.Follow the repository's PR description template by including the required sections: 'Changes', 'Checklist' (with verification steps), and 'Release Impact' (confirming changeset generation).
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely summarizes the main change: fixing revalidation of nested fields when a parent object field is updated via setFieldValue.
      Linked Issues check✅ PassedThe code changes fully address the linked issue #2113: they implement revalidation of mounted nested fields when a parent object field is updated via setFieldValue, including a regression test that verifies the fix.
      Out of Scope Changes check✅ PassedAll changes are directly scoped to fixing issue #2113: adding revalidation logic to setFieldValue, updating changelogs, and adding a regression test.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.

Sign in to join this conversation.