From 4ff9b2acad914920e88ed9a3b17e489df7166698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Bono?= Date: Fri, 31 May 2024 21:48:36 +0200 Subject: [PATCH] feat: open item in new window when pressing ctrl/meta key --- frontend/src/components/files/ListingItem.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/files/ListingItem.vue b/frontend/src/components/files/ListingItem.vue index 01937c8a..3bb32ece 100644 --- a/frontend/src/components/files/ListingItem.vue +++ b/frontend/src/components/files/ListingItem.vue @@ -211,12 +211,14 @@ const drop = async (event: Event) => { const itemClick = (event: Event | KeyboardEvent) => { if ( singleClick.value && - !(event as KeyboardEvent).ctrlKey && - !(event as KeyboardEvent).metaKey && + !( + fileStore.selectedCount !== 0 && + ((event as KeyboardEvent).ctrlKey || (event as KeyboardEvent).metaKey) + ) && !(event as KeyboardEvent).shiftKey && !fileStore.multiple ) - open(); + open(event); else click(event); }; @@ -230,7 +232,7 @@ const click = (event: Event | KeyboardEvent) => { touches.value++; if (touches.value > 1) { - open(); + open(event); } if (fileStore.selected.indexOf(props.index) !== -1) { @@ -270,8 +272,13 @@ const click = (event: Event | KeyboardEvent) => { fileStore.selected.push(props.index); }; -const open = () => { - router.push({ path: props.url }); +const open = (event: Event | KeyboardEvent) => { + if ((event as KeyboardEvent).ctrlKey || (event as KeyboardEvent).metaKey) { + const route = router.resolve({ path: props.url }); + window.open(route.href, "_blank"); + } else { + router.push({ path: props.url }); + } }; const getExtension = (fileName: string): string => {