From 844e17502a15f9a38155ae5125051378c795655e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bragi=20Berg=C3=BE=C3=B3rsson?= Date: Wed, 5 Jan 2022 10:20:09 +0000 Subject: [PATCH] Adds callbacks for shortcuts --- src/InternalEvents.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/InternalEvents.tsx b/src/InternalEvents.tsx index 38075ce..0263234 100644 --- a/src/InternalEvents.tsx +++ b/src/InternalEvents.tsx @@ -144,7 +144,7 @@ function useDocumentLock() { * performs actions for patterns that match the user defined `shortcut`. */ function useShortcuts() { - const { actions, query } = useKBar((state) => ({ + const { actions, query, options } = useKBar((state) => ({ actions: state.actions, })); @@ -180,8 +180,10 @@ function useShortcuts() { if (action.children?.length) { query.setCurrentRootAction(action.id); query.toggle(); + options.callbacks?.onOpen?.(); } else { action.command?.perform(); + options.callbacks?.onSelectAction?.(action); } buffer = [];