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;