Skip to content

fix(form-core): handle null field defaults - #2429

Open
fenet-as wants to merge 1 commit into
TanStack:mainfrom
fenet-as:fix/is-default-value-null
Open

fenet-as wants to merge 1 commit into
TanStack:mainfrom
fenet-as:fix/is-default-value-null

Conversation

@fenet-as

@fenet-as fenet-as commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

  • Fix isDefaultValue to respect an explicit field-level defaultValue: null.
  • Update resetField to fall back to the form-level default only when the field-level default is undefined.
  • Add a regression test covering field-level null defaults, value changes, and resets.

Fixes #2427

Summary by CodeRabbit

  • Bug Fixes
    • Field-level defaultValue: null is now respected when checking whether a field has its default value and when resetting a field or form. Fields with undefined defaults continue to use the form-level default.

@changeset-bot

changeset-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e7169e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@tanstack/form-core Patch
@tanstack/angular-form Patch
@tanstack/form-devtools Patch
@tanstack/lit-form Patch
@tanstack/preact-form Patch
@tanstack/react-form Patch
@tanstack/solid-form Patch
@tanstack/svelte-form Patch
@tanstack/vue-form Patch
@tanstack/react-form-devtools Patch
@tanstack/solid-form-devtools Patch
@tanstack/react-form-nextjs Patch
@tanstack/react-form-remix Patch
@tanstack/react-form-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/form/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07ff809e-c847-46a6-9b72-3cf2bb2cc6e0

📥 Commits

Reviewing files that changed from the base of the PR and between 2216fde and e7169e6.


📒 Files selected for processing (3)
  • .changeset/null-field-default-value.md
  • packages/form-core/src/FormApi.ts
  • packages/form-core/tests/FieldApi.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

Field-level defaultValue: null is now used when resolving isDefaultValue and when resetField selects a value. Tests cover value changes, field reset, and form reset. A patch changeset describes the behavior.

Changes

Field Default Resolution

Layer / File(s) Summary
Resolve and reset nullable field defaults
packages/form-core/src/FormApi.ts, packages/form-core/tests/FieldApi.spec.ts, .changeset/null-field-default-value.md
Default-status checks and resetField use a field-level null default. The tests verify the default status after value changes, field reset, and form reset. The changeset records the update.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low


Merge Risk: ⚪ Minimal · up to e7169

No actionable issue remains from this review; the change appears ready to merge after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description explains the change, motivation, regression test, and linked issue. It does not use the required Changes, Checklist, or Release Impact sections, and it omits the required checklist and… Rewrite the description using the repository template. Add the Changes, Checklist, and Release Impact sections, then mark the applicable checklist items and confirm the changeset status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: handling null field defaults in form-core.
Linked Issues check Passed The PR addresses the coding requirements in #2427. FormApi now treats a field-level defaultValue: null as the selected default and uses the form-level default only when the field default is `undef…
Out of Scope Changes check Passed The changes stay within the linked issue scope. The FormApi fix implements null field-default handling, the FieldApi test verifies the regression, and the form-core changeset documents the behavio…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…

Full details: Description check

Explanation

The description explains the change, motivation, regression test, and linked issue. It does not use the required Changes, Checklist, or Release Impact sections, and it omits the required checklist and release-impact selections.


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
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.

isDefaultValue is wrong when a field-level defaultValue is null

1 participant