huntabyte / cmdk-sv

cmdk, but for Svelte ✨
https://cmdk-sv.com
MIT License
410 stars 17 forks source link

How to get input value from Command.Input? #76

Closed CyMathew closed 2 months ago

CyMathew commented 2 months ago

As a corollary to #13, I'm trying to use Command.Input to keep a value in sync with the underlying input but it looks like on:change event is never called. And on:input only returns a single key input at a time. How would I get this to work?

<script>
   let query: string = "";
</script>

<Command.Root>
        <Command.Input
        value={query}
        on:change={(e) => query = e.currentTarget.value} or
                on:input={(e) => query = e.currentTarget.value}
    />
    <Command.List>
          ...
    </Command.List>
</Command.Root>
huntabyte commented 2 months ago

bind:value={query}

CyMathew commented 2 months ago

Thank you. I can't believe I forgot about bind and tried to do it the React way.