Open
Description
Describe the bug
When removing array elements, currently subfields with falsy values on the last row are being changed to undefined. Added a condition to specifically check for undefined.
This is critical as the casting converting booleans or empty strings to undefined leads to uncontrolled inputs in React and overall strange behavior regarding validators that expect particular value types.
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-6huqeq8i?file=src%2FApp.tsx,src%2Fcomponents%2FForm.tsx
Steps to reproduce
- Click the push value button twice so you have three rows.
- Click the Log button and inspect the console.
- Notice that interests logs:
[
{
"id": "01965a86-4995-768a-85b9-be02512c2208",
"interestName": ""
},
{
"id": "01965a86-4ab7-751b-9368-8ce7539f2e49"
"interestName": undefined
}
]
interestName is now missing! It was overwritten as undefined
Expected behavior
Falsy values remain stable after removing field value.
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
Replicatable on any code sandbox/React environment
TanStack Form adapter
react-form
TanStack Form version
1.6.3
TypeScript version
5.7.2
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels