Skip to content

[Select] onValueChange vs onChange #2700

Answered by cschroeter
veloware asked this question in Q&A
Discussion options

You must be logged in to vote

@veloware

Multiple selection works fine using <Select.Root multiple /> (see video).

Regarding the API design, you have several options:

Option A

Integrate the form library directly into your component.

Option B

Split the relevant props between the root and the hidden select.

const { name, onChange, onBlur, ref, ...rootProps } = props;
return (
  <Select.Root {...rootProps} name={name} onChange={onChange} onBlur={onBlur}>
    <Select.HiddenSelect ref={ref} name={name} onChange={onChange} onBlur={onBlur} />
  </Select.Root>
);

Option C

Allow direct access to the hidden select.

const App = () => {
  return <MySelect hiddenSelectProps={register("framework")} />;
};
Screen.Recording.2024-0…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@veloware
Comment options

@cschroeter
Comment options

Answer selected by veloware
@veloware
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants