pacocoursey / cmdk

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

Custom filter doesn't apply until search term exists #32

Open brodyd795 opened 2 years ago

brodyd795 commented 2 years ago

I'm trying to provide a custom filter to filter out items based on the URL before the user even enters a search term, and it's not working because the current implementation renders all items by default (ignoring filtering) until the search term is provided. I believe this line is where that functionality is written.

I'd like to see an implementation that allows the custom filter to be applied even before there's a search term.

pacocoursey commented 2 years ago

Hey, interesting issue. Any reason you can't skip rendering those items instead of relying on a filter?

{urlMatch && <Item>Only shown then URL matches</Item>}
brodyd795 commented 2 years ago

Hey, interesting issue. Any reason you can't skip rendering those items instead of relying on a filter?

{urlMatch && <Item>Only shown then URL matches</Item>}

I tried that, but that also doesn't solve the issue of things not sorting properly, and I still want to show those items in case my guess (based on the URL) was wrong.