Input doesn't get focused on setError with shouldFocusError
See original GitHub issueDescribe the bug
Field doesn’t get focused with manual setError
when useForm
has option shouldFocusError: true
To Reproduce Steps to reproduce the behavior:
- Fill the last name and submit
- See error and focus are not set
Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-useform-template-forked-wj5o6?file=/src/index.js
Expected behavior First name field is focused on error
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS Catalina 10.15.5
- Browser: Chrome
- Version: v84.0.4147.135
Additional context I would happy to take this issue if this behaviour is not expected. Thanks for awesome work
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
reactjs - How to focus when an error occurs in react-hook-form ...
You can use setFocus from RHF. First, detect when the errors object changes and then find the first field which has the object...
Read more >useForm - setError - React Hook Form
Should focus the input during setting an error. This only works when the input's reference is registered, it will not work for custom...
Read more >Form validation with react-hook-form - DEV Community
If I submit the form with an empty password, I will not get any error message that indicate I forgot to input my...
Read more >react-hook-form useForm TypeScript Examples
export function Dashboard() { const { errors, setError, register, formState, ... setError } = useForm(); const onSubmit = async (data) => { //...
Read more >Create powerful and flexible forms with React Hook Form
React Form Hook is a React library that is used to make performant, ... const { setError, errors } = useForm(); <input name="username" ......
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
Thanks, didn’t thought about that. If user set error manually it totaly makes sense to control it with options
I don’t think it should by default,
setError
?