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
pull/108114/head^2
Jack Westbrook 4 days ago committed by GitHub
parent c7aa83f8d3
commit 0d2657e2f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      public/app/features/commandPalette/KBarResults.tsx
  2. 2
      public/app/features/commandPalette/actions/useExtensionActions.ts

@ -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') {

@ -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]);
}

Loading…
Cancel
Save