Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus doesn't work on select when form is validate. #2661

Closed
Pieszczoch opened this issue Jan 23, 2024 · 4 comments
Closed

Focus doesn't work on select when form is validate. #2661

Pieszczoch opened this issue Jan 23, 2024 · 4 comments
Labels

Comments

@Pieszczoch
Copy link

Pieszczoch commented Jan 23, 2024

When my form is validate on select, it doesn't focus on him like on input (react-hook-form + zod)
this is how it looks like on input: https://ui.shadcn.com/docs/components/input
and this on select: https://ui.shadcn.com/docs/components/select

Radix package @radix-ui/react-select

@liuhe2020
Copy link

liuhe2020 commented Jan 31, 2024

You need to pass in the ref from your form field down to the select component, and note that select itself does not accept ref, but select trigger does, so you could just copy and past shadcn select example code for form

Add this <SelectTrigger ref={field.ref}>

Make sure you wrap all your fields in your form inside FormField and FormItem, otherwise the validation focus order gets out of whack

@Pieszczoch
Copy link
Author

unfortunately, it does't work :(

@benoitgrelard
Copy link
Contributor

Duplicate of #2659 2659

@lsdev200
Copy link

lsdev200 commented May 7, 2024

it is worked for me .
thanks

You need to pass in the ref from your form field down to the select component, and note that select itself does not accept ref, but select trigger does, so you could just copy and past shadcn select example code for form

Add this <SelectTrigger ref={field.ref}>

Make sure you wrap all your fields in your form inside FormField and FormItem, otherwise the validation focus order gets out of whack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants