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

[v4] Removing last item in array field doesn't clean up its errors #3748

Closed
logaretm opened this issue Apr 10, 2022 · 0 comments
Closed

[v4] Removing last item in array field doesn't clean up its errors #3748

logaretm opened this issue Apr 10, 2022 · 0 comments
Labels
🐛 bug Unintended behavior

Comments

@logaretm
Copy link
Owner

logaretm commented Apr 10, 2022

What

I've updated the codesandbox demo and it's working a lot better, but I'm still having an issue or two.

If you open it again and remove the LAST row from the form, it shows the form is not valid and therefore can't be submitted. Removing any other row seems to be fine.

Originally posted by @danh65 in #3732 (reply in thread)

Why

This issue is caused by the field value changing momentarily to be undefined since it no longer exists in the array, that is when a validation run is executed against that field before it is removed. However since the removal part is done synchronously the field is removed before the validation is concluded which then sets the errors for that non-existent field.

We either need to skip the validation run altogether or make sure it is ignored.

@logaretm logaretm changed the title Thank you @logaretm, that gets me further! I've updated the [codesandbox demo](https://codesandbox.io/s/delicate-microservice-366jye) and it's working a lot better, but I'm still having an issue or two. [v4] Removing last item in array field doesn't clean up its errors Apr 10, 2022
@logaretm logaretm added the 🐛 bug Unintended behavior label Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant