Replies: 1 comment
-
@Bliqui To disable autofocus when using useFieldArray in React Hook Form, you should set shouldFocus={false} in the method call that triggers the focus, such as append, insert, or prepend. For instance, you can pass shouldFocus={false}, For example : const { fields, prepend, remove } = useFieldArray({ const handleAdd = () => { |
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.
-
I've made autosave logic. When the user stops typing, I submit the form (after the data from backend is injected to the form through the useForm's values option). Everything works great except for the fields from the useFieldArray hook. On form submission, the input focus moves to the first input from the first FieldArray object. I understand that values may rerender that's why the focus is lost and I found a way to handle the focus by myself, but I can't disable RHF's autofocus.
TL;DR: Does anyone know how I could disable focus handling by rhf?
Beta Was this translation helpful? Give feedback.
All reactions