Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of objects from nested arrays doesn't work as expected #1171

Open
Oudwins opened this issue Feb 22, 2025 · 1 comment
Open

Removal of objects from nested arrays doesn't work as expected #1171

Oudwins opened this issue Feb 22, 2025 · 1 comment
Labels

Comments

@Oudwins
Copy link

Oudwins commented Feb 22, 2025

Describe the bug

When removing an object from a nested array only the "id" field is removed from the element. This happens both if you use arrayField.removeValue and form.setFieldValue.

Your minimal, reproducible example

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

Steps to reproduce

  1. Head to the stack bliz
  2. Click on any of the rendered codes (except the last one, that one works correctly)
  3. You will see in the console the logs of the data before and after each step. You will also see a react key error and can verify that although the object was removed the log that shows the data after the update shows the object that was removed without a id field

Expected behavior

The object is correctly removed. No key error is triggered. React renders the new list correctly.

How often does this bug happen?

Every time

Screenshots or Videos

tanstack-form-issue.mp4

Platform

  • OS: Linux
  • Browser: chrome, brave

TanStack Form adapter

None

TanStack Form version

^0.43.2

TypeScript version

No response

Additional context

Example is a little chaotic. Monday I can clean it up. But I think the video shows what is happening quite well.

@crutchcorn crutchcorn added the bug label Feb 25, 2025
@Oudwins
Copy link
Author

Oudwins commented Feb 25, 2025

Updated the code to be simpler. Let me know if the issue is clear enough if not I'm happy to polish up the example more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants