KBARResults: Add Cmd+Enter/Ctrl+Enter to open links in new tab (#107537)

* KBARResults:add command+enter to open selected link in new tab
pull/107722/head
Yunwen Zheng 2 weeks ago committed by GitHub
parent 37c480def4
commit a2a28b207c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      public/app/features/commandPalette/KBarResults.tsx

@ -71,7 +71,18 @@ export const KBarResults = (props: KBarResultsProps) => {
}
return nextIndex;
});
} else if (event.key === 'Enter' && !event.metaKey) {
} else if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
// Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux) - open in new tab
event.preventDefault();
if (activeRef.current instanceof HTMLAnchorElement) {
window.open(activeRef.current.href, '_blank', 'noopener,noreferrer');
query.toggle();
} else {
// For action-based items (rendered as <div> tags), execute normally
activeRef.current?.click();
}
} else if (event.key === 'Enter' && !event.metaKey && !event.ctrlKey) {
event.preventDefault();
// storing the active dom element in a ref prevents us from
// having to calculate the current action to perform based

Loading…
Cancel
Save