huntabyte / cmdk-sv

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

Feature request: support debouncing search value changes #37

Closed Not-Jayden closed 7 months ago

Not-Jayden commented 7 months ago

I'm already noticing some performance issues when searching through >100 results, so I was looking into how I might be able to support debouncing, however it seems like the search filtering behaviour is pretty baked into the updateState function logic used in the CommandInput action function. I thought using createState would be the solve, but that doesn't include the updateState method, and just manually updating the state search property doesn't perform all the filtering and other logic side effects included in updateState

The quickest and easiest solution I can think of is to expose the complete state store with the updateState method as a slot prop in the Command element. That way I can redefine the command input action with the updateState call debounced.

I'll put a PR up for that if you're happy with it as a solution, but wanted to check in whether there might be something more obvious that is currently achievable without any changes that I'm missing, or if there's any other preferable solution you can think of than using slot props.