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

[Yup] yup resolver overrides ref property in errors object with validation metadata when using checkbox input #630

Open
marko-hologram opened this issue Sep 20, 2023 · 0 comments

Comments

@marko-hologram
Copy link

Describe the bug
When using yup resolver, ref property in errors object doesn't contain the HTML element, but contains some object with metadata related to that field's validation. When not using yup, ref property contains the actual HTML element.

Basic text input is not affected by this.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/p/sandbox/dazzling-butterfly-zs8899?file=/src/App.tsx
  2. Open browser dev tools Console tab
  3. Click on "Submit" below form "Form with Yup"
  4. Observe errors object that is logged and notice how isTosAccepted object ref property contains some metadata and not the actual HTML input element like other fields

Library versions:
@hookform/resolvers - v3.0.0
react-hook-form - v7.43.9

Codesandbox link (Required)
https://codesandbox.io/p/sandbox/dazzling-butterfly-zs8899?file=/src/App.tsx

Expected behavior
When using yup resolver, errors object should contain ref to checkbox input when it's present in a form and validated. Validation without yup resolver contains ref to the checkbox input and I would expect resolver behavior to match the library default one.

Screenshots
Errors object without using yup resolver. Notice how ref is actually the HTML input checkbox.

image

Errors object when using yup resolver. Notice how ref doesn't contain the HTML input checkbox.

image

Desktop (please complete the following information):

  • OS: [Windows]
  • Browser [Firefox, Chrome]
  • Version [Firefox 117, Chrome 116]

Smartphone (please complete the following information):

Haven't tested on a smartphone.

Additional context
I haven't tested with other resolvers from this library.

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