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

Filtering breaks on Svelte-5 #92

Open
cam-mcevenue opened this issue Jul 19, 2024 · 8 comments
Open

Filtering breaks on Svelte-5 #92

cam-mcevenue opened this issue Jul 19, 2024 · 8 comments

Comments

@cam-mcevenue
Copy link

This may be related to issue. #89

When upgrading to svelte-5 filtering breaks on the command component in shadcn-svelte. Docs mention to report issues here.

Stackblitz reproducing issue:

https://stackblitz.com/edit/stackblitz-starters-whbv8w?file=package.json

Steps to reproduce:

There is a delay when running the dev environment in stackblitz, not sure why, so you may have to refresh the page a bunch before the filter count shows properly at the top of the command list

  1. The filter count of the cmdk state is shown at the top of the list

  2. Typing in the input, you can see the results are filtered on the store, but some of the command items that should be filtered out still show in the command list

  3. They are not selectable, and can't be navigated to with the keyboard, but still display

  4. DOwn grade to svelte 4 (npm i svlete@latest)

  5. Everything works as expected

@PudottaPommin
Copy link

I managed to make it work for time being with wrapping <Command.Group> with key. It destroys and recreates whole block, but it's working atm

{#key items}
    <Command.Group>
         {#each items as item}
             ....
         {/each}
     </Command.Group>
{/key}

@OTheNonE
Copy link

Seems like it's being worked on here (just to add the relation).

@juanpujol
Copy link

Started to break here: [email protected]

@wd-David
Copy link

Workaround (https://github.com/sveltejs/svelte/releases/tag/svelte%405.0.0-next.220):

Recreate Command.Group whenever input is changed.

<script>
let search = $state('')
</script>

<Command.Root>
  <Command.Input placeholder="Search framework..." bind:value={search} />
  {#key search}
    <Command.Group>
      {#each frameworks as framework}
        <Command.Item>
        ...
        </Command.Item>
      {/each}
    </Command.Group>
  {/key}
</Command.Root>

@huntabyte
Copy link
Owner

Can't debug anything related to Svelte 5 when the prod version of the library is Svelte 4. These issues will be addressed once the Svelte 5 version of this project is released! Thank you!

@huntabyte huntabyte closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
@huntabyte
Copy link
Owner

Just to add some additional context, we're pretty confident this PR specifically broke cmdk-sv: sveltejs/svelte#12215

Per sveltejs/svelte#10359 (comment) it doesn't seem like the backward compatibility applies to this library

I'm working on the Svelte 5 version, but running into similar issues (duplicate items). Hopefully, I will be able to resolve them with help from the Svelte team 😃

@huntabyte huntabyte reopened this Sep 23, 2024
@dhust
Copy link

dhust commented Oct 25, 2024

Duplicate names after typing in letters and backspacing is resolved with @WP-David's key solution.

@huntabyte
Copy link
Owner

If you're using Svelte 5, it's recommended to use the Command component from bits-ui@next instead of cmdk-sv https://next.bits-ui.com/docs/components/command - this specific project is going to be archived in favor of the component living in Bits.

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

7 participants