`Controller`: validate `onBlur` + `shouldFocusError` seemingly not working properly
See original GitHub issueDescribe the bug
When using a Controller
wraps a MUI TextField
it does not seem to neither trigger validation onBlur nor focus the field.
To Reproduce Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/react-hook-form-material-ui-helpers-h7swy
- Fill in “a” in First name (has
minLength
4
) - Tab to next field (trigger blur )
- Click Submit
Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-material-ui-helpers-h7swy
Expected behavior
- at 3. - it first name should have been validated and turned into an error
- at 4. - it should focus “First name” as it’s the first - and only - field with an error
Desktop (please complete the following information):
- OS: OSX
- Browser: Chrome
- Version: 86.0.4240.111
Additional context
Have a look at RHFTextField
, in a simplified way it basically does what’s described in the documentation.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
react hook form onblur not working - You.com | The AI Search ...
react-hook-form/react-hook-form`Controller`: validate `onBlur` + `shouldFocusError` seemingly not working properly#3277. Created about 2 years ago.
Read more >react-hook-form: Validation not working when using onBlur ...
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >TS Support | React Hook Form - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >Create powerful and flexible forms with React Hook Form
Learn how to create performant, flexible, and extensible forms with easy-to-use validation with React Hooks.
Read more >Fire HTML5 validation onblur - HTML & CSS - SitePoint Forums
I thought there would be a validate() function that I could call for ... in the right direction, but it's not perfect yet...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you can up vote this feature request: https://github.com/react-hook-form/react-hook-form/issues/2842
Amazingly quick response btw. Cheers 🙇 🙏