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

Field Array move doesn't update dirtyFields #3819

Closed
AlexanderMeheus opened this issue Jan 2, 2021 · 0 comments
Closed

Field Array move doesn't update dirtyFields #3819

AlexanderMeheus opened this issue Jan 2, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@AlexanderMeheus
Copy link

Describe the bug
When using the move method of the useFieldArray hook, the dirtyFields of the formState only get the right value after being touched. When using a checkbox this needs to be clicked twice to update the dirtyFields.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the sandbox and show the console
  2. Click on the move button
  3. Notice an empty dirtyFields object in the logs
  4. Uncheck the checked checkbox
  5. Notice no log for dirtyFields in the console
  6. Check the same checkbox again
  7. Notice only this checked attribute in the dirtyFields and not the name attributes
  8. Touch a name field and loose focus again
  9. Notice this name field shows up in the dirtyFields

Codesandbox link (Required)
Include a codesandbox will help us to investigate the issue quicker.

Expected behavior
The dirtyFields object is updated when moving fieldArray fields based on the defaultValue of the fieldArray.

Desktop (please complete the following information):

  • OS: macOS Catalina v10.15.7
  • Browser: Google Chrome Version 87.0.4280.88

Additional context
Using react-hook-form v6.14.0

@bluebill1049 bluebill1049 added status: under investigation aware of this issue and pending for investigation bug Something isn't working and removed status: under investigation aware of this issue and pending for investigation labels Jan 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants