Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom loop prop function for virtualization #299

Open
Lexachoc opened this issue Sep 1, 2024 · 0 comments
Open

Support custom loop prop function for virtualization #299

Lexachoc opened this issue Sep 1, 2024 · 0 comments

Comments

@Lexachoc
Copy link

Lexachoc commented Sep 1, 2024

https://github.com/pacocoursey/cmdk?tab=readme-ov-file#command-cmdk-root

<Command loop />

I wonder if it is possible to pass a custom function for the loop prop? So that when using e.g. TanStack Virtual. The <Command.Item can be looped from the virtual end instead of from the end in the dom.
(Please correct me if I use the wrong word, I'm new to react).

Currently, when using the TanStack Virtual + loop prop, it behaves like this:
recording

It is normal and as expected to go down from the top with the arrow, but when going up, the item does not reach the end of the virtual list, but the end of the dom. Same for when doing up from the bottom, the item does not reach the top of the virtual list, but the top of the dom.

So it would be nice to have a custom function for loop prop to scroll to top/bottom:
e.g., call parentRef.current?.scrollTo({ top: 0}); when reaching the bottom of the list, and press the down arrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant