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
Inconsistent isDirty state when resetting a form that's initialized with incomplete defaultValues #11541
Comments
I ran into the same issue, resetting the the form sets the |
Provide a valid codesandbox: https://codesandbox.io/p/sandbox/relaxed-hill-ss3fl6?file=%2Fsrc%2FApp.tsx |
Should be accessible now: https://codesandbox.io/p/sandbox/relaxed-hill-ss3fl6?file=%2Fsrc%2FApp.tsx |
missing |
…reset` api * related #11541 improve dirty check when undefined provided with reset api * early exit when no values provided
Version Number
7.50.1
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/relaxed-hill-ss3fl6?file=%2Fsrc%2FApp.tsx
Steps to reproduce
-> formState.isDirty stays true
Expected behaviour
formState.isDirty
to befalse
after reset ORformState.isDirty
to betrue
after initializiation.Note that the form is initialized with a partial defaultValues object (not all fields are part of the default values object). This results in a form state where
isDirty
isfalse
, as expected.After modifying a field and calling
reset()
theisDirty
staystrue
. This only the case if not all fields are part of defaultValues. One could argue that the form state is different from the default values, since the field is not included in the defaultValues, and thus it should stay dirty. I wouldn't argue this since it's not what one would expect IMO. But still, if you go with that argument, then this means the form should already be dirty from the start.What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: