TanStack / TanStack/form

Default value on field is overwriting default value on useAppForm

Open
#1,538 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

Describe the bug

As mentioned in the title if you have a default value on a form.AppField this overwites the value coming from useAppForm for async loading. Hierarchically these should be overwritten from parent.

Prio

  1. useAppForm defaultValue
  2. formOptions defaultValue
  3. form.AppField defaultValue
Your minimal, reproducible example

https://codesandbox.io/p/sandbox/frosty-james-mwktlf

Steps to reproduce
  1. Create a useAppForm with defaultValue
  2. Declare an empty string or countryCode for a field as default value if no value exists
  3. Have defaultValue from base
  4. Expect defaultValue change on root to overwrite fieldDefaultValue
Expected behavior

Expect defaultValue change on root to overwrite fieldDefaultValue

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

Windows
Chrome 136.0.7103.114

TanStack Form adapter

None

TanStack Form version

^1.11.1

TypeScript version

^5.8.3

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and trace how default values from useAppForm, formOptions, and form.AppField are combined during async loading. Verify the precedence described in the issue, with a root useAppForm defaultValue overriding the field-level defaultValue when it changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.