Skip to content
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

issue: register/unregister should affect isDirty in formState #11815

Closed
1 task done
yslpn opened this issue Apr 24, 2024 · 0 comments
Closed
1 task done

issue: register/unregister should affect isDirty in formState #11815

yslpn opened this issue Apr 24, 2024 · 0 comments

Comments

@yslpn
Copy link

yslpn commented Apr 24, 2024

Version Number

7.51.3

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/amazing-mahavira-29tzmd

Steps to reproduce

  1. Click Submit, and we receive a message in alert
    {"data":{"firstName":"Ivan","lastName":"Ivanov"},"isDirty":false}

  2. Click button unregister lastname field

  3. Click Submit, and we receive a message in alert
    {"data":{"firstName":"Ivan"},"isDirty":false}

Expected behaviour

In our project, we often come across a situation where we have an optional field. We register it or unregister using the checkbox. We don't want to store the checkbox state in the form and want to disable the sumbit button when the data hasn't changed.

We are faced with the fact that we have unregister/register fields, the data that goes into the submit function changes, but the form is not considered isDirty.

Should we change the behavior for isDirty in the library or do we need to create a new field?

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants