form icon indicating copy to clipboard operation
form copied to clipboard

Deleted fields with defaultValue are restored on re-render after deleteField()

Open kusiewicz opened this issue 3 months ago • 0 comments

Describe the bug

When calling form.deleteField('fieldName') on a field that has a defaultValue defined, the field is successfully removed from form.state.values. However, after React re-renders, the field automatically reappears with its defaultValue, making it impossible to truly delete fields with default values.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-cnn3izz6?file=src%2Fapp.tsx

Steps to reproduce

  1. Go to the StackBlitz example
  2. Click remove fullname button
  3. Look on live state

Expected behavior

After calling form.deleteField('fieldName'), the field should:

  • Be permanently removed from form.state.values
  • Stay removed even after React re-renders
  • Not be restored by any internal lifecycle methods

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

everywhere

TanStack Form adapter

None

TanStack Form version

1.23.4

TypeScript version

^5

Additional context

No response

kusiewicz avatar Oct 14 '25 18:10 kusiewicz