feat: Add searching of sub actions in command menu (#2845)

This commit is contained in:
Tom Moor
2021-12-11 09:34:16 -08:00
committed by GitHub
parent 7c6ce44fe1
commit e5b4186faa
7 changed files with 88 additions and 52 deletions

View File

@@ -102,20 +102,12 @@ export function actionToKBar(
name: resolvedName,
section: resolvedSection,
placeholder: resolvedPlaceholder,
keywords: `${action.keywords || ""} ${children
.filter((c) => !!c.keywords)
.map((c) => c.keywords)
.join(" ")}`,
keywords: `${action.keywords}`,
shortcut: action.shortcut || [],
icon: resolvedIcon
? React.cloneElement(resolvedIcon, {
color: "currentColor",
})
: undefined,
icon: resolvedIcon,
perform: action.perform
? () => action.perform && action.perform(context)
: undefined,
children: children.length ? children.map((a) => a.id) : undefined,
},
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
].concat(children.map((child) => ({ ...child, parent: action.id })));