-
-
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
SimpleForm isDirty is always true if ArrayInput is used #9661
Comments
Reproduced, thanks! Until this is fixed, you can use the same workaround we used in const { dirtyFields, isValidating, isSubmitting } = useFormState();
// useFormState().isDirty might differ from useFormState().dirtyFields (https://github.com/react-hook-form/react-hook-form/issues/4740)
const isDirty = Object.keys(dirtyFields).length > 0; |
Yes. We use the same workaround. 🙏 Just one hint, this only works partially. If I change one value in the array input and then revert the changes the field is still listed in the |
I am not sure if I should open separate issue or just comment in this issue. so I will start with a comment and maybe separate it if needed. I am facing relatively same inconveniences with ArrayInput and dirty behaviour. in my case, I am using zod resolver. What you were expecting:
What happened instead: react-admin-react-hook-form-isDirty-issue.mp4Steps to reproduce: here are the two stackblitz that reproduces the two behaviours
Other information: |
I think this issue on react-hook-form side is related |
What you were expecting:
What happened instead:
isDirty
property using theuseFormState()
hook from react-hook-form is set totrue
isDirty
is stillfalse
but becomestrue
in the following renderings (see console output in the sandbox)dirtyFields
are still empty as expecteddefaultValues
the source of the ArrayInputgroups
disappears after the first rendering (see console output in the sandbox)Steps to reproduce:
Related code:
Other information:
isDirty
worked with [email protected]Environment
The text was updated successfully, but these errors were encountered: