From 0d2657e2f0991c236708099af8e6a476d38802fb Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 17 Jul 2025 08:03:39 +0200 Subject: [PATCH] Fix: Link path not recognised in CommandPalette link extensions (#108162) * fix(extensions-ui): commandpalette links should work with urls / paths * fix(commandpalette): block navigation if url exists before calling perform --- public/app/features/commandPalette/KBarResults.tsx | 4 ++++ .../features/commandPalette/actions/useExtensionActions.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/features/commandPalette/KBarResults.tsx b/public/app/features/commandPalette/KBarResults.tsx index 2eb8a5aecf7..020c57ec42f 100644 --- a/public/app/features/commandPalette/KBarResults.tsx +++ b/public/app/features/commandPalette/KBarResults.tsx @@ -121,6 +121,10 @@ export const KBarResults = (props: KBarResultsProps) => { const url = (item as ActionImpl & { url?: string }).url; if (item.command) { + if (url) { + // If the item also has a url we should block navigation. + ev.preventDefault(); + } item.command.perform(item); // TODO: ideally the perform method would return some marker or we would have something like preventDefault() if (!item.id.startsWith('scopes/') || item.id === 'scopes/apply') { diff --git a/public/app/features/commandPalette/actions/useExtensionActions.ts b/public/app/features/commandPalette/actions/useExtensionActions.ts index 1050fb0deb9..112bdc5ab0d 100644 --- a/public/app/features/commandPalette/actions/useExtensionActions.ts +++ b/public/app/features/commandPalette/actions/useExtensionActions.ts @@ -22,8 +22,8 @@ export default function useExtensionActions(): CommandPaletteAction[] { priority: EXTENSIONS_PRIORITY, id: link.id, name: link.title, - target: link.path, perform: () => link.onClick && link.onClick(), + url: link.path, })); }, [links]); }