fix: Action children not triggerable

This commit is contained in:
Tom Moor
2023-02-10 22:36:00 -05:00
parent fcbd4d3d28
commit 237313a97d

View File

@@ -18,7 +18,8 @@ function resolve<T>(value: any, context: ActionContext): T {
export function createAction(definition: Optional<Action, "id">): Action {
return {
...definition,
perform: (context) => {
perform: definition.perform
? (context) => {
// We muse use the specific analytics name here as the action name is
// translated and potentially contains user strings.
if (definition.analyticsName) {
@@ -32,7 +33,8 @@ export function createAction(definition: Optional<Action, "id">): Action {
}
return definition.perform?.(context);
},
}
: undefined,
id: uuidv4(),
};
}
@@ -115,7 +117,7 @@ export function actionToKBar(
keywords: action.keywords ?? "",
shortcut: action.shortcut || [],
icon: resolvedIcon,
perform: () => action.perform?.(context),
perform: action.perform ? () => action.perform?.(context) : undefined,
},
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
].concat(children.map((child) => ({ ...child, parent: action.id })));