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: value of double depth arrays lost when one entry is unregistered #7849

Closed
1 task done
jorrit opened this issue Feb 18, 2022 · 1 comment · Fixed by #7859
Closed
1 task done

issue: value of double depth arrays lost when one entry is unregistered #7849

jorrit opened this issue Feb 18, 2022 · 1 comment · Fixed by #7859
Labels
bug Something isn't working

Comments

@jorrit
Copy link

jorrit commented Feb 18, 2022

Version Number

7.27.0

Codesandbox/Expo snack

https://codesandbox.io/s/funny-edison-sqdvk9

Steps to reproduce

  1. Enter something in name 1, observe that the dumped value changes
  2. Check the checkbox. This enables another field.
  3. Enter something in name 2, observe that the dumped value changes
  4. Uncheck the checkbox. This unregisters the new field.
  5. Observe that the dumped value is empty, even though the first field still contains a value.

Expected behaviour

After unregistering items.1.0.name, the value for items.0.0.name should still be in the watched value when watching items.

When I use a single-depth array this works fine (so items.0.name instead of items.0.0.name).

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
@jorrit
Copy link
Author

jorrit commented Feb 18, 2022

This CodeSandbox uses shouldUnregister instead of unregister() with the same effect:

https://codesandbox.io/s/charming-cherry-ptenpl?file=/src/App.tsx

@bluebill1049 bluebill1049 added the bug Something isn't working label Feb 18, 2022
bluebill1049 added a commit that referenced this issue Feb 19, 2022
* fix #7849 issue with unset on multiple demision array

* remove no check
bluebill1049 added a commit that referenced this issue Mar 13, 2022
* fix #7849 issue with unset on multiple demision array

* remove no check
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 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