-
Notifications
You must be signed in to change notification settings - Fork 9
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
HasManyFields mixes up values of uncontrolled inputs in rows #751
Comments
The easy workaround is to just use
|
uh so I'm pretty sure I caused this bug 😅 I think most of the time developers should pass an array of objects that each have a
If not since we already have |
I guess, but It would be just as bad to regenerate the keys with every render. Instead of the wrong uncontrolled input being unmounted (this bug), all uncontrolled inputs would remounted and lose their values(pre #535)! I agree with your type suggestion, but it is a bit more complicated since the So maybe a future fix could be to remove HMF uncontrolled capability, and enforce the |
I believe the cause is using indices as keys for rows combined with using uncontrolled inputs. Since we remap the HMF value after each change, the
HMFRow
keys will always be 0 to {value.length - 1}. When react reconciles, it deletes the last row because its key no longer exists. With controlled inputs the last row is still deleted, but this isn't a problem because the values are also reassigned.STR:
O:
D: Uncontrolled inputs should properly stay with the Rows they were created on
Here's a PR with a story that reproduces the bug:
#750
The text was updated successfully, but these errors were encountered: