From 68aea19e7b60dc69c10b8cabc32f8fd07a393d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 11 Jan 2024 17:07:43 +0100 Subject: [PATCH] make sure we dont use history api if user wants to open in a new tab. --- .../src/external/router-slot/util/anchor.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/external/router-slot/util/anchor.ts b/src/Umbraco.Web.UI.Client/src/external/router-slot/util/anchor.ts index 437fd78afc..b0fff6303c 100644 --- a/src/Umbraco.Web.UI.Client/src/external/router-slot/util/anchor.ts +++ b/src/Umbraco.Web.UI.Client/src/external/router-slot/util/anchor.ts @@ -3,7 +3,12 @@ * that has a relative HREF, uses the history API instead. */ export function ensureAnchorHistory() { + const isWindows = navigator.platform.toUpperCase().indexOf('WIN') !== -1; + window.addEventListener('click', (e: MouseEvent) => { + // If we try to open link in a new tab, then we want to skip skip: + if ((isWindows && e.ctrlKey) || (!isWindows && e.metaKey)) return; + // Find the target by using the composed path to get the element through the shadow boundaries. const $anchor = (('composedPath' in e) as any) ? e.composedPath().find(($elem) => $elem instanceof HTMLAnchorElement)