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

zodResolver / superRefine / useFieldArray: useForm errors are not updated to reflect zodResolver errors #672

Open
stefan-girlich opened this issue Mar 25, 2024 · 1 comment

Comments

@stefan-girlich
Copy link

stefan-girlich commented Mar 25, 2024

Describe the bug
Only changes to the last field in a field array are considered for validation when using superRefine. Changes to other fields are validated by zodResolver, but the resulting errors are not updated.

To Reproduce
Rule for all scenarios: names must be unique

Scenario 1:

  1. Open sandbox link below
  2. Change second input to "foo" to provoke error
  3. Change first input to "bar" to resolve error
    => zodResolver error disappears, react-hook-form error remains (incorrectly)

Scenario 2:

  1. Open sandbox link below
  2. Change first input to "bar" to provoke error
    => react-hook-form errors are not updatefd (incorrectly)

Scenario 3 (positive):

  1. Open sandbox link below
  2. Change second input to "foo" to provoke error
  3. Change second input back to "bar" to resolve error
    => zodResolver and react-hook-form errors disappear

Codesandbox link (Required)
Link

Expected behavior
zodResolver error states are propagated to the useForm errors regardless of array position

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Brave
  • Version 1.63.169

Additional context
If the error state is reached by editing the first field (see scenario 2 above), the error from zodResolver is missing the ref object. This seems to be the missing link.

@upauliushchyk
Copy link

I have same issue react-hook-form/react-hook-form#11833

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

2 participants