From 7fc37f05dc94b6a18334500993d0cf8ca981905d Mon Sep 17 00:00:00 2001 From: Diego Pucci Date: Tue, 16 Apr 2024 13:18:49 +0200 Subject: [PATCH 1/2] Support edit chart new window click --- .../components/SliceHeaderControls/index.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx index 3890c596e8e0d..e546b51f0c713 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx @@ -590,7 +590,12 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => { case MenuKeys.ExploreChart: // eslint-disable-next-line no-unused-expressions props.logExploreChart?.(props.slice.slice_id); - window.open(props.exploreUrl); + if (domEvent.metaKey || domEvent.ctrlKey) { + domEvent.preventDefault(); + window.open(props.exploreUrl, '_blank'); + } else { + history.push(props.exploreUrl); + } break; case MenuKeys.ExportCsv: // eslint-disable-next-line no-unused-expressions @@ -672,6 +677,7 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => { supersetCanShare = false, isCached = [], } = props; + const history = useHistory(); const isTable = slice.viz_type === 'table'; const cachedWhen = (cachedDttm || []).map(itemCachedDttm => moment.utc(itemCachedDttm).fromNow(), @@ -907,16 +913,6 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => { placement="bottomRight" visible={dropdownIsOpen} onVisibleChange={status => toggleDropdown({ close: !status })} - onBlur={e => { - // close unless the dropdown menu is clicked - const relatedTarget = e.relatedTarget as HTMLElement; - if ( - dropdownIsOpen && - menuRef?.current?.props.id !== relatedTarget?.id - ) { - toggleDropdown({ close: true }); - } - }} onKeyDown={e => handleDropdownNavigation( e, From dfce4bd158c4971ba109d36c6f9a7612012c1deb Mon Sep 17 00:00:00 2001 From: Diego Pucci Date: Tue, 16 Apr 2024 13:21:12 +0200 Subject: [PATCH 2/2] Clean up --- .../src/dashboard/components/SliceHeaderControls/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx index e546b51f0c713..e3a5db0ca78e0 100644 --- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx +++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx @@ -529,6 +529,7 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => { const [openScopingModal, scopingModal] = useCrossFiltersScopingModal( props.slice.slice_id, ); + const history = useHistory(); const queryMenuRef: RefObject = useRef(null); const menuRef: RefObject = useRef(null); @@ -677,7 +678,6 @@ const SliceHeaderControls = (props: SliceHeaderControlsPropsWithRouter) => { supersetCanShare = false, isCached = [], } = props; - const history = useHistory(); const isTable = slice.viz_type === 'table'; const cachedWhen = (cachedDttm || []).map(itemCachedDttm => moment.utc(itemCachedDttm).fromNow(),