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

Reset Multi-mode Listbox (React) #2603

Closed
tsr-rise8 opened this issue Jul 19, 2023 · 1 comment · Fixed by #2626
Closed

Reset Multi-mode Listbox (React) #2603

tsr-rise8 opened this issue Jul 19, 2023 · 1 comment · Fixed by #2626
Assignees

Comments

@tsr-rise8
Copy link

tsr-rise8 commented Jul 19, 2023

All information can be seen in this discussion post.

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.14

What browser are you using?

Chrome

Reproduction URL

<form
  onSubmit={(e) => {
    e.preventDefault()
    handleSubmission(Object.fromEntries(new FormData(e.target as HTMLFormElement)))
  }}
>
  <Listbox
    name="assignee"
    by="id"
    defaultValue={[] as { id: number; name: string; label: string }[]}
    multiple
  >
    <Listbox.Button>
      {({ value }) =>
        value.length > 0
          ? value.map((v: { id: number; name: string; label: string }) => v.name)
          : 'Trigger'
      }
    </Listbox.Button>
    <Listbox.Options>
      {data.map((person) => (
        <Listbox.Option key={person.id} value={person}>
          {person.label}
        </Listbox.Option>
      ))}
    </Listbox.Options>
  </Listbox>
  <button id="submit">submit</button>
  <button type="reset" id="reset">
    reset
  </button>
</form>

I tried to open a PR since it is a small issue undeserving of a whole repo for reproducing but was denied access.

Describe your issue

See the discussion post from above.

@thecrypticace
Copy link
Contributor

Hey, thanks for the report! This should be fixed by #2626, and will be available in the next release.

You can already try it using — though it may take a few minutes before it is available on NPM:

  • npm install @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders.

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

Successfully merging a pull request may close this issue.

3 participants