pacocoursey / cmdk

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

<Command.Empty> showing when using react-window and react-virtualized-autosizer #282

Open BrendanC23 opened 4 months ago

BrendanC23 commented 4 months ago

Here's a CodeSandbox that demonstrates the issue.

I'm trying to virtualize cmdk using the react-window package. This works fine (see the "virtualized cmdk without autosize" demo). All of the elements are displayed properly. When FixedSizeList is used, I need to set the items to take up a certain height. If there are too few items, empty space will be rendered.

One fix for this is to use [react-virtualized-auto-sizer] (https://github.com/bvaughn/react-virtualized-auto-sizer), which will dynamically change the height. However, this causes the <Command.Item /> elements to no longer render, and instead the <Command.Empty /> element is shown. The "virtualized cmdk with autosize" demo shows "no items found".

imyuanli commented 2 months ago

I have the same problem,do you have any solution?

imyuanli commented 2 months ago

I have currently solved it in a rather stupid way, but this still needs a real solution image