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
TYPE: enhancement New feature or request WAITING FOR: Qwik V2 This will be implemented when Qwik V2 is released

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...

Edit:

Might be easier in V2.

@shairez shairez converted this from a draft issue Jun 12, 2024
@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 labels Jun 12, 2024
@shairez shairez moved this from Backlog to Upcoming in Qwik UI Development Jul 10, 2024
@maiieul maiieul added TYPE: enhancement New feature or request and removed TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply P2: minor labels Jul 18, 2024
@shairez shairez added the WAITING FOR: Qwik V2 This will be implemented when Qwik V2 is released label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: enhancement New feature or request WAITING FOR: Qwik V2 This will be implemented when Qwik V2 is released
Projects
Status: Backlog
Development

No branches or pull requests

3 participants