albingroen / react-cmdk

A fast, accessible, and pretty command palette for React
https://react-cmdk.com
MIT License
1.1k stars 45 forks source link

[feature] Customize filtering #37

Open tchock opened 1 year ago

tchock commented 1 year ago

Currently the filtering of the search results with filterItems() are quite plain (it just filters with .includes() of the items array).

Adding a custom filtering function to filterItems() would be really nice, it could make it possible to do more complex filtering without the need to copy paste and adjust the filterItems function to your own codebase.

Background: I am building a way to execute commands, like a function, but through the command palette. The function arguments are prompted to the user one by one, with options being displayed in the list as some kind of auto correction. I want to add a way to select multiple options with a glob pattern and it would be nice to already preview all the matching options.

I don't want to reproduce the nested filtering logic that already is included in filterItems, so a custom filtering function would be quite handy.