From ad2bce9c104046041410a13855e6bb4a6fabb211 Mon Sep 17 00:00:00 2001 From: Saumya Pandey Date: Sat, 26 Feb 2022 10:09:03 +0530 Subject: [PATCH] fix: sync the correct collection with edit action (#3166) * fix: sync the correct collection with edit action * fix: remove action suggestions on undefined * Update app/hooks/useCommandBarActions.ts Co-authored-by: Tom Moor --- app/actions/index.ts | 2 +- app/hooks/useCommandBarActions.ts | 6 +++++- app/scenes/Collection.tsx | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/actions/index.ts b/app/actions/index.ts index 3d271a98e..d8322681c 100644 --- a/app/actions/index.ts +++ b/app/actions/index.ts @@ -95,7 +95,7 @@ export function actionToKBar( name: resolvedName, section: resolvedSection, placeholder: resolvedPlaceholder, - keywords: `${action.keywords}`, + keywords: action.keywords ?? "", shortcut: action.shortcut || [], icon: resolvedIcon, perform: action.perform diff --git a/app/hooks/useCommandBarActions.ts b/app/hooks/useCommandBarActions.ts index 42869366c..9722f73a6 100644 --- a/app/hooks/useCommandBarActions.ts +++ b/app/hooks/useCommandBarActions.ts @@ -11,7 +11,10 @@ import useActionContext from "./useActionContext"; * * @param actions actions to make available */ -export default function useCommandBarActions(actions: Action[]) { +export default function useCommandBarActions( + actions: Action[], + additionalDeps: React.DependencyList = [] +) { const location = useLocation(); const context = useActionContext({ isCommandBar: true, @@ -24,5 +27,6 @@ export default function useCommandBarActions(actions: Action[]) { useRegisterActions(registerable, [ registerable.map((r) => r.id).join(""), location.pathname, + ...additionalDeps, ]); } diff --git a/app/scenes/Collection.tsx b/app/scenes/Collection.tsx index 164b20b04..9266f71da 100644 --- a/app/scenes/Collection.tsx +++ b/app/scenes/Collection.tsx @@ -93,7 +93,10 @@ function CollectionScene() { load(); }, [collections, isFetching, collection, error, id, can]); - useCommandBarActions([editCollection]); + useCommandBarActions( + [editCollection], + ui.activeCollectionId ? [ui.activeCollectionId] : undefined + ); if (!collection && error) { return ;