From a03ba3962e5cf8bb738233fe9d1b20c0460d21d9 Mon Sep 17 00:00:00 2001 From: samcaspus Date: Mon, 20 Jul 2020 00:17:53 -0700 Subject: [PATCH 1/3] enhanced ctrl + click new tab opening feature --- frontend/src/layout/Sidebar.js | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/frontend/src/layout/Sidebar.js b/frontend/src/layout/Sidebar.js index 539900638dc0f..93999ace175af 100644 --- a/frontend/src/layout/Sidebar.js +++ b/frontend/src/layout/Sidebar.js @@ -65,7 +65,11 @@ const submenuOverride = { export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { const [inviteModalOpen, setInviteModalOpen] = useState(false) const [toolbarModalOpen, setToolbarModalOpen] = useState(false) - const collapseSidebar = () => { + const collapseSidebar = (url) => (e) => { + if (e.ctrlKey) { + console.log(e) + window.open(url, '_blank') + } if (!sidebarCollapsed && window.innerWidth <= 991) { setSidebarCollapsed(true) } @@ -132,14 +136,17 @@ export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { > {dashboard.name} - + ))} Dashboards - + {pinnedDashboards.length > 0 ? : null} @@ -147,7 +154,7 @@ export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { {'Trends'} - + {'All Events'} - + {'Actions'} - + {'Live Actions'} - + {'Sessions'} - + {'All Users'} - + {'Cohorts'} - + {'Retention'} - + {'Funnels'} - + {'Paths'} - + {'Experiments'} - + {'Setup'} - + Date: Mon, 20 Jul 2020 02:50:13 -0700 Subject: [PATCH 2/3] worked on review changes reverted and fixed over link.js component --- frontend/src/layout/Sidebar.js | 40 +++++++++++------------------ frontend/src/lib/components/Link.js | 4 +++ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/frontend/src/layout/Sidebar.js b/frontend/src/layout/Sidebar.js index 93999ace175af..539900638dc0f 100644 --- a/frontend/src/layout/Sidebar.js +++ b/frontend/src/layout/Sidebar.js @@ -65,11 +65,7 @@ const submenuOverride = { export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { const [inviteModalOpen, setInviteModalOpen] = useState(false) const [toolbarModalOpen, setToolbarModalOpen] = useState(false) - const collapseSidebar = (url) => (e) => { - if (e.ctrlKey) { - console.log(e) - window.open(url, '_blank') - } + const collapseSidebar = () => { if (!sidebarCollapsed && window.innerWidth <= 991) { setSidebarCollapsed(true) } @@ -136,17 +132,14 @@ export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { > {dashboard.name} - + ))} Dashboards - + {pinnedDashboards.length > 0 ? : null} @@ -154,7 +147,7 @@ export function Sidebar({ user, sidebarCollapsed, setSidebarCollapsed }) { {'Trends'} - + {'All Events'} - + {'Actions'} - + {'Live Actions'} - + {'Sessions'} - + {'All Users'} - + {'Cohorts'} - + {'Retention'} - + {'Funnels'} - + {'Paths'} - + {'Experiments'} - + {'Setup'} - + { + if (event.ctrlKey) { + window.open(to, '_blank') + } + if (!props.target) { event.preventDefault() event.stopPropagation() From f78ef53e969691b76b8ac6c8cb54431f07ed50ec Mon Sep 17 00:00:00 2001 From: samcaspus Date: Mon, 20 Jul 2020 03:04:38 -0700 Subject: [PATCH 3/3] add return method for ctrl click and command click --- frontend/src/lib/components/Link.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/Link.js b/frontend/src/lib/components/Link.js index 4d1ca12d98a66..f6443aabb6bcc 100644 --- a/frontend/src/lib/components/Link.js +++ b/frontend/src/lib/components/Link.js @@ -7,8 +7,8 @@ export function Link({ to, preventClick = false, ...props }) { href={to || '#'} {...props} onClick={(event) => { - if (event.ctrlKey) { - window.open(to, '_blank') + if (event.metaKey || event.ctrlKey) { + return window.open(to, '_blank') } if (!props.target) {