-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Ghost validation error when removing item from ArrayInput with nested ArrayInput #9961
Comments
#9839 might be related or the same issue |
Reproduced, thanks for the report. It seems the issue disappears if you set const TestEdit = () => {
return (
<Edit>
<SimpleForm shouldUnregister>
<Form />
</SimpleForm>
</Edit>
);
}; This can't be considered as a fix for the issue, but may be used as a workaround. |
I tried to reproduce the issue in a RHF only sandbox, to see if the issue came from their code or ours, but couldn't reproduce the issue there (https://codesandbox.io/p/sandbox/calc-forked-hp97w7), which seems to indicate this affects react-admin only. Also, I realize it is possible to set |
As seen in #10271, |
I managed to reproduce it with react-hook-form alone, based on @slax57 's Codesandbox: https://codesandbox.io/p/sandbox/calc-forked-93m7f3?workspaceId=3123472d-a31f-4ddf-a4e0-79c596270dc0 The key difference is to use a So this is definitely a react-hook-form bug. I'll open an issue in their tracker. |
Nope, false alarm, I didn't manage to reproduce it with react-hook-form alone. Still investigating. |
React-hook-form v7.53.1 seems to fix a related issue, but the bug is still present in react-admin with this version. |
OK, it IS a react-hook-form issue, as I reproduced it in the following sandbox that doesn't use react-admin: https://codesandbox.io/p/sandbox/calc-forked-93m7f3?workspaceId=3123472d-a31f-4ddf-a4e0-79c596270dc0 I have reported the problem to react-hook-form (see react-hook-form/react-hook-form#12385) |
What you were expecting:
Removing an item form an ArrayInput should not cause validation errors on non-existent fields
What happened instead:
After I removed the item and validated the form, there was a validation error for a no longer existing index
Steps to reproduce:
Have an ArrayInput with items which also have ArrayInputs. The arrays as well as their items are validated as required.
Codesandbox: https://codesandbox.io/p/devbox/nested-arrayinput-remove-item-issue-hz4yq8
The form is invalid, there is a validation error for the 4th item's nested array.
React.App.-.Google.Chrome.2024-06-27.14-44-32.mov
Related code:
Other information:
The issue is reproducible with version 5 as well: https://codesandbox.io/p/devbox/nested-arrayinput-remove-item-issue-forked-8shcyl
Environment
The text was updated successfully, but these errors were encountered: