Add search filtering to CommandDialog for improved script search functionality (#10800)

This commit is contained in:
Bram
2026-01-14 10:08:44 +01:00
committed by GitHub
parent 277d1ed5a2
commit bf648203f0
2 changed files with 23 additions and 5 deletions
+15 -2
View File
@@ -194,7 +194,20 @@ function CommandMenu() {
</TooltipProvider>
</div>
<CommandDialog open={open} onOpenChange={setOpen}>
<CommandDialog
open={open}
onOpenChange={setOpen}
filter={(value: string, search: string) => {
const searchLower = search.toLowerCase().trim();
if (!searchLower)
return 1;
const valueLower = value.toLowerCase();
const searchWords = searchLower.split(/\s+/).filter(Boolean);
// All search words must appear somewhere in the value (name + description)
const allWordsMatch = searchWords.every((word: string) => valueLower.includes(word));
return allWordsMatch ? 1 : 0;
}}
>
<DialogTitle className="sr-only">Search scripts</DialogTitle>
<CommandInput placeholder="Search for a script..." />
<CommandList>
@@ -204,7 +217,7 @@ function CommandMenu() {
{scripts.map(script => (
<CommandItem
key={`script:${script.slug}`}
value={`${script.name}-${script.type}`}
value={`${script.name} ${script.type} ${script.description || ""}`}
onSelect={() => {
setOpen(false);
router.push(`/scripts?id=${script.slug}`);