Closed cbaum86 closed 1 year ago
I will investigate this.
I fixed your Code Sandbox: https://codesandbox.io/s/white-glade-i26wqu?file=/src/App.js:4459-4626
The issue is Password has an inputRef
the main ref
points to the wrapper DIV of the password.
<Password
{...field}
inputRef={field.ref}
type="password"
placeholder="password input"
/>
could you please update your example code using this fix on the react-form-hook example? it took me a while to figure it out: https://www.primefaces.org/primereact/reacthookform/
@hugomf I updated the showcase for the next major deployment with a Password React Hook Example.
Describe the bug
When using Password component with React Hook Form, on submit, if the password is the only field to fail validation then React Hook Form attempts to put a focus on the password field but cannot and throws an error.
Standard input text and password fields work as expected, as does a password input wrapped in a div as generated by Prime React.
Reproducer
https://codesandbox.io/s/blissful-butterfly-pc6xhk
PrimeReact version
8.7.2
React version
18.x
Language
ES6
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
With all other fields types, standard html text or password, PrimeReact InputText then when submitting the form, if there are errors the first field with an error is focused on. I would expect that, if the PrimeReact Password component is the first invalid field then the form should focus on this field too.