From 769b4598d71cd50481714bd4731edce44ba0dbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 20 Mar 2023 10:54:10 +0100 Subject: [PATCH] Router: Fix broken link interception and router navigation (#65023) * Router: Fix broken link interception and router navigation * replace with instanceof Element --- public/app/core/navigation/patch/interceptLinkClicks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/core/navigation/patch/interceptLinkClicks.ts b/public/app/core/navigation/patch/interceptLinkClicks.ts index 623df472362..7a83a6f5302 100644 --- a/public/app/core/navigation/patch/interceptLinkClicks.ts +++ b/public/app/core/navigation/patch/interceptLinkClicks.ts @@ -3,7 +3,7 @@ import { locationService, navigationLogger } from '@grafana/runtime'; import { config } from 'app/core/config'; export function interceptLinkClicks(e: MouseEvent) { - const anchor = e.target instanceof HTMLElement ? getParentAnchor(e.target) : null; + const anchor = e.target instanceof Element && getParentAnchor(e.target); // Ignore if opening new tab or already default prevented if (e.ctrlKey || e.metaKey || e.defaultPrevented) { @@ -43,7 +43,7 @@ export function interceptLinkClicks(e: MouseEvent) { } } -function getParentAnchor(element: HTMLElement | null): HTMLElement | null { +function getParentAnchor(element: Element | null): Element | null { while (element !== null && element.tagName) { if (element.tagName.toUpperCase() === 'A') { return element;