Skip to content

fix(react-form): fallback array field value during index change to prevent uncontrolled error #1378

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

Conversation

MVaik
Copy link

@MVaik MVaik commented Apr 5, 2025

Fixes #1363

More of a draft, while this seems to fix the issue it could have unintended side-effects.
Perhaps it's useful in finding a better solution.

What seems to happen:
Have at least 2 array elements that are not keyed by index.
Remove the first element.
This will cause the second element to be moved up, but it attempts to retrieve a value with the old index, resulting in an undefined value for a short bit.

@juanvilladev
Copy link
Contributor

The problem with this is that, we're only addressing the specific value field. This is also a problem with the field meta, and all other values. :/

@juanvilladev
Copy link
Contributor

Hey @MVaik I just opened a PR with a proper fix for this. Feel free to take a look at it!

@MVaik
Copy link
Author

MVaik commented Apr 26, 2025

Closing in favor of #1440

@MVaik MVaik closed this Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-index keys in React causing inputs to be uncontrolled when removing array fields
2 participants