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

Fix Select and Select.ItemLabel composition #839

Open
shairez opened this issue Jun 12, 2024 · 0 comments
Open

Fix Select and Select.ItemLabel composition #839

shairez opened this issue Jun 12, 2024 · 0 comments
Assignees
Labels
P2: minor If it's a bug, it doesn't make Qwik unstable but doesn't have workarounds either TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply

Comments

@shairez
Copy link
Contributor

shairez commented Jun 12, 2024

Currently the styled Select doesn't allow doing

const Item = component$<PropsOf<typeof HeadlessSelect.Item>>(({ ...props }) => {
  return (
    <HeadlessSelect.Item
      {...props}
      class={cn(
        'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
        props.class,
      )}
    >
      <HeadlessSelect.ItemLabel>
        <Slot />
      </HeadlessSelect.ItemLabel>
      <span class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
        <HeadlessSelect.ItemIndicator>
          <LuCheck class="h-4 w-4" />
        </HeadlessSelect.ItemIndicator>
      </span>
    </HeadlessSelect.Item>
  );
});

to consume it like that in the styled kit:

    <Select.Root>
      <Select.Label>Logged in users</Select.Label>
      <Select.Trigger>
        <Select.DisplayText placeholder="Select an option" />
      </Select.Trigger>
      <Select.Popover>
        <Select.Listbox>
          {users.map((user) => (
            <Select.Item key={user}></Select.Item>
          ))}
        </Select.Listbox>
      </Select.Popover>
    </Select.Root>

For that we would need to transform the Headless Select.Item component into an inlined component, which means we would have to make the Select.Item expose a selectItemLabel prop...

@shairez shairez added TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply P2: minor If it's a bug, it doesn't make Qwik unstable but doesn't have workarounds either labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2: minor If it's a bug, it doesn't make Qwik unstable but doesn't have workarounds either TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply
Projects
Status: Backlog
Development

No branches or pull requests

2 participants