pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.42k stars 265 forks source link

arrow keys wrap around #57

Closed Kilian closed 1 year ago

Kilian commented 1 year ago

Allows the arrow keys to wrap around, so when you press "up" from the input you end up at the bottom item, and when you press down while the last item is selected, it wraps around back to the first item in the list.

Fixes #56.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
cmdk-website ✅ Ready (Inspect) Visit Preview Nov 10, 2022 at 2:47PM (UTC)
peduarte commented 1 year ago

I like this, but could this be done via a prop? Radix uses the loop prop for this https://www.radix-ui.com/docs/primitives/components/dropdown-menu#content

Kilian commented 1 year ago

@peduarte you mean make it optional based on a loop prop? Where should it live, Command.Dialog or Command.List?

pacocoursey commented 1 year ago

Let's add an optional loop prop to the Command top-level component for this behavior 👍

peduarte commented 1 year ago

Yeah, I meant an optional loop prop. I'd personally add it to the List Component, since that's where the looping happens. But if @pacocoursey wants to add it to the Command component I'm down

Kilian commented 1 year ago

loop prop added.

peduarte commented 1 year ago

very nice