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

Select in controlled mode doesn't show the current value #140

Closed
jcmonnin opened this issue Apr 28, 2022 · 4 comments
Closed

Select in controlled mode doesn't show the current value #140

jcmonnin opened this issue Apr 28, 2022 · 4 comments

Comments

@jcmonnin
Copy link

Describe the bug
The Select component in controlled mode doesn't seem to update when the selected value is updated externally.

To Reproduce
Adding a button to the example form the documentation
https://hope-ui.com/docs/data-entry/select#controlled

function Example() {
  const [value, setValue] = createSignal("");

  return (
    <>
      <Button onClick={() =>setValue("Solid")}>Set Solid</Button>
      <Text mb="$2">Value: {value()}</Text>
      <Select value={value()} onChange={setValue}>
        <SelectTrigger>
          <SelectPlaceholder>Choose a framework</SelectPlaceholder>
          <SelectValue />
          <SelectIcon />
        </SelectTrigger>
        <SelectContent>
          <SelectListbox>
            <For each={["React", "Angular", "Vue", "Svelte", "Solid"]}>
              {item => (
                <SelectOption value={item}>
                  <SelectOptionText>{item}</SelectOptionText>
                  <SelectOptionIndicator />
                </SelectOption>
              )}
            </For>
          </SelectListbox>
        </SelectContent>
      </Select>
    </>
  )
}

Expected behavior
When clicking on "Set Solid" button I would expect that both the text and select show "Solid" (Only the text updates, and the Select component stays out of sync).

Versions
This happens both in 0.4.2 and 0.4.4

@fabien-ml
Copy link
Collaborator

Hi, fixed in v0.4.5. available on the next tag.

@jcmonnin
Copy link
Author

Thanks. That's a quick fix!
I can confirm 0.4.5 fixes the issue.
Thank you so much for doing this great library.
I introduce shamelessly a feature request here: it would be great to have sliders.

@fabien-ml
Copy link
Collaborator

The slider component is planned, however i'm currently focusing on solid-aria first before adding new components because it will be the new (and more robust) foundation of Hope UI.

@jcmonnin
Copy link
Author

Great to hear sliders are planned.

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

No branches or pull requests

2 participants