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

View File

@@ -24,13 +24,18 @@ const Command = React.forwardRef<
));
Command.displayName = CommandPrimitive.displayName;
type CommandDialogProps = {} & DialogProps;
type CommandDialogProps = {
filter?: (value: string, search: string, keywords?: string[]) => number;
} & DialogProps;
function CommandDialog({ children, ...props }: CommandDialogProps) {
function CommandDialog({ children, filter, ...props }: CommandDialogProps) {
return (
<Dialog {...props}>
<DialogContent className="overflow-hidden p-0 shadow-lg">
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
<Command
filter={filter}
className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
>
{children}
</Command>
</DialogContent>