react-hook-form-antd icon indicating copy to clipboard operation
react-hook-form-antd copied to clipboard

TypeError: elm.focus is not a function

Open snndmnsz opened this issue 1 year ago โ€ข 4 comments

I get this error when i put Upload component inside FormItem. Probably <Control/> cannot find the focus bcs of Upload uses button. How can i resolve this?

Ekran Resmi 2024-08-09 02 26 21

Error source: Ekran Resmi 2024-08-09 02 30 10

snndmnsz avatar Aug 08 '24 23:08 snndmnsz

Have you tried to use the solution in #83 ?

jsun969 avatar Aug 09 '24 11:08 jsun969

@jsun969 Yes, I did, but it didn't work. I found the solution, tho. React Hook Form tries to focus on the error state. Since upload components have no focusable elements, it throws an "elm.focus is not a function" error. If you set shouldFocusError: false in your useForm, it fixes the problem, but you can't use the focus-on-error functionality anymore. Could you please add this problem to the .md file of this package so that everyone who wants to use uploads in their form can resolve this issue?

snndmnsz avatar Aug 09 '24 17:08 snndmnsz

Yea we should add it in readme. Do you want to make a PR for it?

jsun969 avatar Aug 10 '24 01:08 jsun969

Yeah, sure.

snndmnsz avatar Aug 10 '24 14:08 snndmnsz