fix(form-core): preserve prefix-matching sibling fields #2318
main fromrefs/pull/2318/head·merged by LeCarbonator(GitHub profile, opens in a new tab) 🎯 Changes#
- Restrict
deleteFielddescendant cleanup to dot- and bracket-delimited field paths. - Preserve values, registrations, and metadata for sibling fields that only share a string prefix.
- Add regression coverage for object fields and nested array fields.
Fixes #2317
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Bug Fixes
- Fixed field deletion so it removes only the selected field and its true nested descendants.
- Preserved sibling fields whose names share a prefix with the deleted field.
- Improved handling for nested object and array field paths.
- 1
View your CI Pipeline Execution ↗ for commit aad81e62332d836b8a7b493a4209b814fc3ed462
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 4m 31s View ↗ nx run-many --target=build --exclude=examples/**✅ Succeeded 41s View ↗
☁️ Nx Cloud last updated this comment at
2026-08-11 07:34:49UTC🧹 Nitpick comments (1)
packages/form-core/tests/FieldApi.spec.ts (1)
3390-3395: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that the deleted fields are removed.
This test only checks the surviving siblings. A no-op
deleteFieldimplementation would still pass. Add assertions for the deleted fields’ values,fieldInfo, and metadata.Suggested assertions
form.deleteField('email') form.deleteField('items[0].price') + expect(form.getFieldValue('email')).toBeUndefined() + expect(form.fieldInfo.email).toBeUndefined() + expect(form.state.fieldMeta.email).toBeUndefined() expect(form.getFieldValue('emailVerified')).toBe(true) expect(form.fieldInfo.emailVerified).toBeDefined() expect(form.state.fieldMeta.emailVerified).toBeDefined() + expect(form.getFieldValue('items[0].price')).toBeUndefined() + expect(form.fieldInfo['items[0].price']).toBeUndefined() + expect(form.state.fieldMeta['items[0].price']).toBeUndefined() expect(form.getFieldValue('items[0].priceCurrency')).toBe('USD')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/form-core/tests/FieldApi.spec.ts` around lines 3390 - 3395, Extend the test around the field deletion scenario to assert that each deleted field no longer has a value, fieldInfo entry, or fieldMeta entry. Keep the existing assertions for surviving sibling fields, and verify the removed paths directly through getFieldValue, form.fieldInfo, and form.state.fieldMeta.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@packages/form-core/tests/FieldApi.spec.ts`: - Around line 3390-3395: Extend the test around the field deletion scenario to assert that each deleted field no longer has a value, fieldInfo entry, or fieldMeta entry. Keep the existing assertions for surviving sibling fields, and verify the removed paths directly through getFieldValue, form.fieldInfo, and form.state.fieldMeta.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
9b74da01-b286-4b1f-b2e1-e69e589d867a📥 Commits
Reviewing files that changed from the base of the PR and between 462926e3b77e9c0ad6a777a879ef5067b0a5dc70 and aad81e62332d836b8a7b493a4209b814fc3ed462.
📒 Files selected for processing (3)
.changeset/tidy-forms-keep.mdpackages/form-core/src/FormApi.tspackages/form-core/tests/FieldApi.spec.ts
More templates
- @tanstack/form-example-angular-array
- @tanstack/form-example-angular-large-form
- @tanstack/form-example-angular-multi-step-wizard
- @tanstack/form-example-angular-simple
- @tanstack/form-example-angular-standard-schema
- @tanstack/form-example-lit-array
- @tanstack/form-example-lit-large-form
- @tanstack/form-example-lit-multi-step-wizard
- @tanstack/form-example-lit-simple
- @tanstack/form-example-lit-standard-schema
- @tanstack/form-example-lit-ui-libraries
- @tanstack/form-example-preact-multi-step-wizard
- @tanstack/form-example-preact-simple
- @tanstack/form-example-react-array
- @tanstack/form-example-react-compiler
- @tanstack/form-example-react-composition
- @tanstack/form-example-react-devtools
- @tanstack/form-example-react-dynamic
- @tanstack/form-example-react-expo
- @tanstack/field-errors-from-form-validators
- @tanstack/form-example-react-large-form
- @tanstack/form-example-react-multi-step-wizard
- @tanstack/form-example-react-next-server-actions
- @tanstack/form-example-react-next-server-actions-zod
- @tanstack/form-example-react-query-integration
- @tanstack/form-example-remix
- @tanstack/form-example-react-simple
- @tanstack/form-example-react-standard-schema
- @tanstack/form-example-react-tanstack-start
- @tanstack/form-example-react-ui-libraries
- @tanstack/form-example-solid-array
- @tanstack/form-example-solid-devtools
- @tanstack/form-example-solid-large-form
- @tanstack/form-example-solid-multi-step-wizard
- @tanstack/form-example-solid-simple
- @tanstack/form-example-solid-standard-schema
- @tanstack/form-example-svelte-array
- @tanstack/form-example-svelte-large-form
- @tanstack/form-example-svelte-multi-step-wizard
- @tanstack/form-example-svelte-simple
- @tanstack/form-example-svelte-standard-schema
- @tanstack/form-example-vue-array
- @tanstack/form-example-vue-multi-step-wizard
- @tanstack/form-example-vue-simple
- @tanstack/form-example-vue-standard-schema
@tanstack/angular-form
npm i https://pkg.pr.new/@tanstack/angular-form@2318@tanstack/form-core
npm i https://pkg.pr.new/@tanstack/form-core@2318@tanstack/form-devtools
npm i https://pkg.pr.new/@tanstack/form-devtools@2318@tanstack/lit-form
npm i https://pkg.pr.new/@tanstack/lit-form@2318@tanstack/preact-form
npm i https://pkg.pr.new/@tanstack/preact-form@2318@tanstack/react-form
npm i https://pkg.pr.new/@tanstack/react-form@2318@tanstack/react-form-devtools
npm i https://pkg.pr.new/@tanstack/react-form-devtools@2318@tanstack/react-form-nextjs
npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2318@tanstack/react-form-remix
npm i https://pkg.pr.new/@tanstack/react-form-remix@2318@tanstack/react-form-start
npm i https://pkg.pr.new/@tanstack/react-form-start@2318@tanstack/solid-form
npm i https://pkg.pr.new/@tanstack/solid-form@2318@tanstack/solid-form-devtools
npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2318@tanstack/svelte-form
npm i https://pkg.pr.new/@tanstack/svelte-form@2318@tanstack/vue-form
npm i https://pkg.pr.new/@tanstack/vue-form@2318commit:
aad81e6:warning: Please install the
to ensure uploads and comments are reliably processed by Codecov.
Codecov Report#
:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 89.78%. Comparing base (
6892ed0) to head (aad81e6). :warning: Report is 267 commits behind head on main. :exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.Additional details and impacted files
@@ Coverage Diff @@ ## main #2318 +/- ## ========================================== - Coverage 90.35% 89.78% -0.57% ========================================== Files 38 66 +28 Lines 1752 3232 +1480 Branches 444 812 +368 ========================================== + Hits 1583 2902 +1319 - Misses 149 296 +147 - Partials 20 34 +14:umbrella: View full report in Codecov by Harness. :loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
LeCarbonator(GitHub profile, opens in a new tab) approved these changes
LGTM! Thanks!
LeCarbonator(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
deleteFieldnow removes only dot- or bracket-delimited descendants. Regression coverage verifies that prefix-sharing sibling fields retain their values, registrations, and metadata. A patch changeset documents the fix.Changes#
Field deletion boundary handling
packages/form-core/src/FormApi.ts,packages/form-core/tests/FieldApi.spec.ts,.changeset/tidy-forms-keep.mddeleteFieldnow matches only dot- and bracket-delimited descendants. Tests verify that sibling fields such asemailVerifiedandpriceCurrencyremain registered with their values and metadata. The changeset documents the patch release.Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested reviewers:
crutchcorn,pascalmh🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#2317by enforcing path boundaries and preserving unrelated sibling fields.✨ Finishing Touches
🧪 Generate unit tests (beta)
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