huntabyte / cmdk-sv

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

CommandDialog auto open or close based on input focus. #56

Closed niemyjski closed 8 months ago

niemyjski commented 8 months ago

This would be really nice to have and I was surprised it wasn't the default behavior. Like I was thinking like it's a normal input box that gets transformed into a command dialog more of an auto complete but a command..

huntabyte commented 8 months ago

Not going to be a feature out of the box as this could be implemented programmatically with little effort. The events for on:focus and on:blur are forwarded already, so you can programmatically do whatever you'd like with the dialog's open state.

niemyjski commented 8 months ago

@huntabyte the problem with this is the input box for on:focus and on:blur change as the command list is shown, so it is not reliable from a usability standpoint. Any recommendations?

andoppomny commented 6 months ago

When you select an item with the mouse, focus on the input element is lost before the onSelect handler is run. So if you hide the command items on blur, the onSelect doesn't get called. Only solution I have found is a timeout on blur to dismiss, which isn't great.