Replies: 1 comment
-
I also noticed that this works if the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.49.3
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/rhf-test-h7dw9w?file=%2Fsrc%2FApp.tsx
Steps to reproduce
Hi
I have found a possible bug in my relatively complex application. To put it short, I have set my form mode to "onBlur", meaning that fields should be validated when ever the user moves focus out of the element. This works fine, but if I also modify the form state during the onBlur event, and the current field value is touched as a part of that process, the result is that the field error cannot be seen in
formState.errors
(even if the field validation function was executed and it returned an error).Now I know no-one can help me to debug the bug with this explanation, so I tried my best to create a minimal example where the bug can be seen. I'm sorry that the example is not completely realistic (it has a field validator which always returns an error message and it also always replaces the filled first name with a hardcoded value), but I hope it explains the problem. Here is how to reproduce the bug:
The error message can be seen, however, if the custom onBlur event is commented out. Why?
EDIT: I also noticed that if I add a minimal timeout at the end of the onBlur event and trigger the validation manually, it works. Why?
Expected behaviour
"YOU HAVE AN ERROR" message should be shown on the screen
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions