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

onChange and onBlur validation errors should prevent submission of form #490

Closed
crutchcorn opened this issue Oct 27, 2023 · 9 comments
Closed
Assignees
Labels
bug good first issue Good for newcomers

Comments

@crutchcorn
Copy link
Member

Currently, when using a field with:

<Field onChange={z.string().min(1)}>

When the user submits the form, it does not show a form error on submit. This causes headaches currently as it makes things harder to workflow properly.

@vikaskumar89
Copy link
Contributor

Hey @crutchcorn
Can you assign this to me please

@MiirzaBaig
Copy link

Can you aasign this issue to me?

@vikaskumar89
Copy link
Contributor

hey @I-MirzaBaig
I am working on this. Could you pick any other open issue.

@MiirzaBaig
Copy link

@vikaskumar89 Alright!

@vikaskumar89
Copy link
Contributor

vikaskumar89 commented Nov 4, 2023

Hey @crutchcorn
The root cause of this error is because we have defined undefined for the submit cause that leads to validateSync returning early and not executing any onBlur/onChange validation.

error rootcause:

if (!validate) return

One solution that comes to my mind is in case of submit cause, we can execute either onChange or onBlur validation(whichever is defined in the field) but this would lead to incorrect errorMap detail in the state as the errorMapKey would be submit and the error would correspond to onChange/onBlur.

Do you have any alternate suggestion to fix this ?

@vikaskumar89
Copy link
Contributor

Due to this errorMap array, we are facing this issue in #486, as the errorMap is not clear after a valid value is entered.

@danteissaias
Copy link

Is there currently a workaround to this?

@vikaskumar89
Copy link
Contributor

@danteissaias yeah fix should be out in a couple of days.

@crutchcorn
Copy link
Member Author

This fix is released in 0.10.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants