question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Controller`: validate `onBlur` + `shouldFocusError` seemingly not working properly

See original GitHub issue

Describe 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:

  1. Go to https://codesandbox.io/s/react-hook-form-material-ui-helpers-h7swy
  2. Fill in “a” in First name (has minLength 4)
  3. Tab to next field (trigger blur )
  4. 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:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bluebill1049commented, Oct 27, 2020

In the case of synchronous validation methods I wouldn’t expect it to ever reach isSubmitting

If one would have have async validation methods I don’t know what would be good - maybe to introduce isValidation

you can up vote this feature request: https://github.com/react-hook-form/react-hook-form/issues/2842

1reaction
KATTcommented, Oct 27, 2020

Amazingly quick response btw. Cheers 🙇 🙏

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found