You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding list items to an array field with form.pushFieldValue, removing items doesn't work correctly if the form is conditionally rendered. The items are removed, but the last item is added back on the end, keeping the array the same length.
For example, if you have items 1, 2, 3, 4 and remove item 2, you are left with 1, 3, 4, 4.
@danielmarcano It only seems to happen if the form is conditionally rendered, so I set the display to none rather than doing conditional rendering, I can make a reproduction later.
Describe the bug
When adding list items to an array field with form.pushFieldValue, removing items doesn't work correctly if the form is conditionally rendered. The items are removed, but the last item is added back on the end, keeping the array the same length.
For example, if you have items 1, 2, 3, 4 and remove item 2, you are left with 1, 3, 4, 4.
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-qgeu9c?file=src/index.tsx&preset=node
Steps to reproduce
Expected behavior
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
react-form
TanStack Form version
v0.33.0
TypeScript version
v5.6.2
Additional context
No response
The text was updated successfully, but these errors were encountered: