resolvers
resolvers copied to clipboard
Zod and async marks all fields as validating instead of only the one
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:
- Set up a schema with a zodResolver and an Async field
- Click on Submit
- Only
usernameis validating asyncronously formState.validatingFieldsis 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.
https://github.com/user-attachments/assets/edc91f22-2749-4ff5-a905-0fa66e9f127c
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: https://github.com/react-hook-form/react-hook-form/issues/5744