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 <tom.moor@gmail.com>
This commit is contained in:
@@ -95,7 +95,7 @@ export function actionToKBar(
|
|||||||
name: resolvedName,
|
name: resolvedName,
|
||||||
section: resolvedSection,
|
section: resolvedSection,
|
||||||
placeholder: resolvedPlaceholder,
|
placeholder: resolvedPlaceholder,
|
||||||
keywords: `${action.keywords}`,
|
keywords: action.keywords ?? "",
|
||||||
shortcut: action.shortcut || [],
|
shortcut: action.shortcut || [],
|
||||||
icon: resolvedIcon,
|
icon: resolvedIcon,
|
||||||
perform: action.perform
|
perform: action.perform
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import useActionContext from "./useActionContext";
|
|||||||
*
|
*
|
||||||
* @param actions actions to make available
|
* @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 location = useLocation();
|
||||||
const context = useActionContext({
|
const context = useActionContext({
|
||||||
isCommandBar: true,
|
isCommandBar: true,
|
||||||
@@ -24,5 +27,6 @@ export default function useCommandBarActions(actions: Action[]) {
|
|||||||
useRegisterActions(registerable, [
|
useRegisterActions(registerable, [
|
||||||
registerable.map((r) => r.id).join(""),
|
registerable.map((r) => r.id).join(""),
|
||||||
location.pathname,
|
location.pathname,
|
||||||
|
...additionalDeps,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,10 @@ function CollectionScene() {
|
|||||||
load();
|
load();
|
||||||
}, [collections, isFetching, collection, error, id, can]);
|
}, [collections, isFetching, collection, error, id, can]);
|
||||||
|
|
||||||
useCommandBarActions([editCollection]);
|
useCommandBarActions(
|
||||||
|
[editCollection],
|
||||||
|
ui.activeCollectionId ? [ui.activeCollectionId] : undefined
|
||||||
|
);
|
||||||
|
|
||||||
if (!collection && error) {
|
if (!collection && error) {
|
||||||
return <Search notFound />;
|
return <Search notFound />;
|
||||||
|
|||||||
Reference in New Issue
Block a user