huntabyte / cmdk-sv

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

[question] How can I access the search input value? #27

Closed fredguth closed 8 months ago

fredguth commented 8 months ago

I am trying to access the search input value. Binding to value in Command.Input binds to the selected Item.

huntabyte commented 8 months ago

I am not able to reproduce what you're describing.

When I bind:value to the <Command.Input /> I am getting the expected behavior. Can you provide a reproduction?

Not-Jayden commented 8 months ago

Are you definitely binding to<Command.Input /> and not <Command.Root /> ? I made that mistake at first as well.

But yeah, binding to <Command.Input /> works as expected for me.

fredguth commented 8 months ago

I am probably doing something wrong. Here is a MWE: https://github.com/fredguth/cmd_mwe/blob/main/src/routes/plus/%2Bpage.svelte

Not-Jayden commented 8 months ago

@fredguth I believe you need to directly bind to the Command.Input value prop inside this component and then export it as an explicit prop. Then you should be able to bind to it in the parent component.

fredguth commented 8 months ago

Thank you all ! I guess @huntabyte already published a fix in shadcn-svelte.

huntabyte commented 8 months ago

Thanks for raising the issue @fredguth! Glad its all worked out!