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

Listbox.Option does not accept ReactNode as children #13031

Open
nboliver-ventureweb opened this issue Jan 7, 2025 · 1 comment · May be fixed by #13145
Open

Listbox.Option does not accept ReactNode as children #13031

nboliver-ventureweb opened this issue Jan 7, 2025 · 1 comment · May be fixed by #13145
Labels
Bug Something is broken and not working as intended in the system. untriaged

Comments

@nboliver-ventureweb
Copy link

Summary

Docs say that ReactNode can be used as children, however, using anything other than a string breaks the layout.

There is a related community thread here:
https://community.shopify.com/c/shopify-apps/polaris-components-combobox-listbox-option-cannot-use-react-node/m-p/2603736#M79181

Expected behavior

You should be able to use any ReactNode as a Listbox.Option child. This will allow custom content in the listbox.

Actual behavior

Adding custom children breaks the layout. If you try to add styled children, it somewhat works, but the accessibility / keyboard controls don't work.

Steps to reproduce

Create a Listbox.Option with custom children:

<Listbox.Option
  key={`${variantId}`}
  value={variantId}
  selected={isSelected}
  accessibilityLabel={title}
>

  <Box width="100%">
    <Text as="p" variant="bodyXs">
      {group}
    </Text>
    {title}
  </Box>
</Listbox.Option>

See the layout is broken:
Image

Are you using React components?

Yes

Polaris version number

@shopify/[email protected]

Browser

Chrome

Device

Macbook Pro

@nboliver-ventureweb nboliver-ventureweb added Bug Something is broken and not working as intended in the system. untriaged labels Jan 7, 2025
@MichaScant
Copy link

Hello, I can work on this issue

@MichaScant MichaScant linked a pull request Jan 29, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system. untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants