From b8d3f488751ffac878afdf60893bdebf00a5b411 Mon Sep 17 00:00:00 2001 From: Kyra Cho Date: Mon, 11 Nov 2024 11:16:04 +0000 Subject: [PATCH] command/ctrl click for "New" action in top nav --- .../top_nav/app_menu_actions/get_new_search.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/main/components/top_nav/app_menu_actions/get_new_search.tsx b/src/plugins/discover/public/application/main/components/top_nav/app_menu_actions/get_new_search.tsx index b67f14f31c56a..48aa8c40abd50 100644 --- a/src/plugins/discover/public/application/main/components/top_nav/app_menu_actions/get_new_search.tsx +++ b/src/plugins/discover/public/application/main/components/top_nav/app_menu_actions/get_new_search.tsx @@ -15,6 +15,10 @@ export const getNewSearchAppMenuItem = ({ }: { onNewSearch: () => void; }): AppMenuActionPrimary => { + let isModifierKeyPressed = false; + document.addEventListener('mousedown', (event: MouseEvent) => { + isModifierKeyPressed = event.metaKey || event.ctrlKey; + }); return { id: AppMenuActionId.new, type: AppMenuActionType.primary, @@ -28,7 +32,13 @@ export const getNewSearchAppMenuItem = ({ iconType: 'plus', testId: 'discoverNewButton', onClick: () => { - onNewSearch(); + const newDiscoverUrl = `${window.location.origin}/app/discover`; + if (isModifierKeyPressed) { + window.open(newDiscoverUrl, '_blank'); + } else { + onNewSearch(); + } + isModifierKeyPressed = false; }, }, };