primitives
primitives copied to clipboard
Support ref in Select Component
Feature request
Overview
The Select component does not allow a ref to be passed to the underlying html select
element. This breaks react-hook-form's register()
function; We are using remix-forms which uses register()
to allow any custom component to be used in a form, as long as it can pass that ref to the underlying select
. @jaimiz expressed the same problem in https://github.com/radix-ui/primitives/issues/1851#issuecomment-1653294400
The needed change is minimal; The Select
component must accept a ref via React.forwardRef
and pass the ref to BubbleSelect
. BubbleSelect
even supports the ref param, but it isn't used. Perhaps Select
was intended to have this behavior originally?
We have already tried the solution in our project with patch-package
and saw it work. I will create a PR with the change shortly. Is there any reason this wouldn't be accepted? Is there an alternative we haven't considered?
Examples in other libraries
N/A
Who does this impact? Who is this for?
- Users of react-hook-form and remix-form