-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
issue: Form obnoxious when combining shouldUseNativeValidation: true and mode: "onBlur" #9290
Comments
thanks for the detailed issue report. After my lengthy investigation, I think this is a limitation when combined with validation onBlur, the reason being when
That's pretty much I will update the doc to exclude onBlur and onTouched modes, in fact, highlight it will only work with onSubmit and onChange modes. |
Documentation is updated. |
@bluebill1049 I was actually thinking that maybe what could be done is that as far as native validation is concerned, This would allow the |
Version Number
7.38.0
Codesandbox/Expo snack
https://codesandbox.io/s/react-hook-form-v7-form-context-forked-p4lfm1?file=/src/index.js:255-312
Steps to reproduce
useForm()
withshouldUseNativeValidation: true
andmode: "onBlur"
Actual behavior: you are not able to take focus away from the input and the browser forces you to fill out the field correctly. Once you do fill it out, the browser repeats the same thing for the next input, and so on. So you're forced to fill out the fields in order, each correctly.
While we're at it: while using a pattern validation: if you do remove
mode: "onBlur"
, for some reason when you first try to type in text in the incorrect pattern format in the input, then go right to "submit", you'll notice that rather than displaying the custom error message you came with, it just says "Please match the requested format".https://codesandbox.io/s/react-hook-form-v7-form-context-forked-p4lfm1?file=/src/index.js
Video:
https://user-images.githubusercontent.com/116494/198707207-f0c51a33-8bf7-4b7e-b7ed-90961e5f6683.mp4
Expected behaviour
Expected: you're able to focus the second input, but the first input's state becomes stored as an error in react-hook-form for displaying JS validation.
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: