issue: "isDirty" and "dirtyFields" work incorrectly after calling "reset" or "setValue"
See original GitHub issueVersion Number
7.17.2
Codesandbox/Expo snack
https://codesandbox.io/s/elegant-goldberg-ebrms
Steps to reproduce
1st Use Case
- Go to https://codesandbox.io/s/elegant-goldberg-ebrms
- Click on ‘SET VALUE’ button
- See
isDirty === falseanddirtyFieldsis empty
2nd Use Case
- Go to https://codesandbox.io/s/elegant-goldberg-ebrms
- Click on ‘SET VALUE’ button
- Change Text field
- See
isDirty === trueanddirtyFields === {"text":true}
3rd Use Case
- Go to https://codesandbox.io/s/elegant-goldberg-ebrms
- Click on ‘RESET’ button
- See
isDirty === falseanddirtyFieldsis empty
4rd Use Case
- Go to https://codesandbox.io/s/elegant-goldberg-ebrms
- Click on ‘RESET’ button
- Change Text field
- See
isDirty === trueanddirtyFields === {"text":true}
Expected behaviour
1st Use Case
isDirty should be true and dirtyFields should contain both fields
2nd Use Case
isDirty should be true and dirtyFields should contain both fields
3rd Use Case
isDirty should be true and dirtyFields should contain both fields
4th Use Case
isDirty should be true and dirtyFields should contain both fields
Explanation: in all use cases the values are different from the default values, so the isDirty flag should be set to true and dirtyFields should contain all the fields that a different from the default values.
I believe this issue relates to the recently closed issue https://github.com/react-hook-form/react-hook-form/issues/6721 and the related discussion https://github.com/react-hook-form/react-hook-form/discussions/6710
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Related StackOverflow Question
case 3 is actually a bug, which incorrectly returns
isDirtystate, and not returningdirtyFields. I will try to patch that after work and do a release if possible.@bluebill1049 thank you very much for addressing the issue quickly! Could you please release a patch version?