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

Zod and async marks all fields as validating instead of only the one #705

Open
walidvb opened this issue Jul 23, 2024 · 0 comments
Open

Comments

@walidvb
Copy link

walidvb commented Jul 23, 2024

Describe the bug
When using async validation refinments, zodResolver seems to be the culprit in marking all fields as validating once the form is being submitted(as opposed to marking only the async refined fields)

To Reproduce
Steps to reproduce the behavior:

  1. Set up a schema with a zodResolver and an Async field
  2. Click on Submit
  3. Only username is validating asyncronously
  4. formState.validatingFields is marking all fields as validating

Interestingly, only clicking the submit button will mark all fields as validating (if validation is triggered by onChange, only the validating field is marked)

Codesandbox link (Required)
https://codesandbox.io/p/sandbox/react-hook-form-async-field-validation-forked-5cclc6?file=%2Fsrc%2Findex.js%3A20%2C18

Expected behavior
formState.validatingFields should only contain the fields that currently have an async validation running. Fields unaffected by that validation should not be contained in that object.

Screenshots
If applicable, add screenshots to help explain your problem.

Screen.Recording.2024-07-23.at.10.43.38.mov

Desktop (please complete the following information):

  • OS: Mac OS 14.2.1
  • Browser: Arc(Chromium)
  • Version [e.g. 22]

I found this issue which seems to be relevant but couldn't find any resolution: react-hook-form/react-hook-form#5744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant