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

[DOCS]: wrong ul>li usage in Listbox example code #3295

Closed
pschaub opened this issue Jun 17, 2024 · 1 comment
Closed

[DOCS]: wrong ul>li usage in Listbox example code #3295

pschaub opened this issue Jun 17, 2024 · 1 comment

Comments

@pschaub
Copy link

pschaub commented Jun 17, 2024

During upgrading my code to the latest Headless UI version, I've seen that the default tags of ListboxOptions and ListboxOption changed, see #3109

I want that my code behaves the same so I was looking for an example in the documentation to change the type back to ul/li on ListboxOptions and ListboxOption.

There I've found this example code:

    <Listbox as="ul" value={selectedPerson} onChange={setSelectedPerson}>
      <ListboxButton as={MyCustomButton}>{selectedPerson.name}</ListboxButton>
      <ListboxOptions anchor="bottom" as="li">
        {people.map((person) => (
          <ListboxOption as="span" key={person.id} value={person} className="data-[focus]:bg-blue-100">
            {person.name}
          </ListboxOption>
        ))}
      </ListboxOptions>
    </Listbox>

I would expect that

  • as="ul" is used on ListboxOptions
  • as="li" is used on ListboxOption

So I suggest to update the documentation example accordingly:

    <Listbox value={selectedPerson} onChange={setSelectedPerson}>
      <ListboxButton as={MyCustomButton}>{selectedPerson.name}</ListboxButton>
      <ListboxOptions anchor="bottom" as="ul">
        {people.map((person) => (
          <ListboxOption as="li" key={person.id} value={person} className="data-[focus]:bg-blue-100">
            {person.name}
          </ListboxOption>
        ))}
      </ListboxOptions>
    </Listbox>
@thecrypticace
Copy link
Contributor

Whoops, appreciate you pointing this out! I've fixed the example code to use ul for ListboxOptions and li for ListboxOption. 👍

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