From fa74a8354b90cc5f31a46f5be93a8dacb986793a Mon Sep 17 00:00:00 2001 From: Rodrigo Cipriani da Rosa Date: Thu, 1 Feb 2024 21:57:17 -0300 Subject: [PATCH] fix: infinity load when in new tab --- src/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index b67d062..ed18be5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,6 +9,8 @@ /* eslint-disable prefer-const */ /* eslint-disable quotes */ +"use client" + import * as PropTypes from 'prop-types'; import * as React from 'react'; import * as NProgress from 'nprogress'; @@ -163,13 +165,14 @@ const NextTopLoader = ({ const target = event.target as HTMLElement; const anchor = findClosestAnchor(target); const newUrl = anchor?.href; + const isNewTab = event.ctrlKey || event.metaKey; if (newUrl) { const currentUrl = window.location.href; // const newUrl = (anchor as HTMLAnchorElement).href; const isExternalLink = (anchor as HTMLAnchorElement).target === '_blank'; const isBlob = newUrl.startsWith('blob:'); const isAnchor = isAnchorOfCurrentUrl(currentUrl, newUrl); - if (newUrl === currentUrl || isAnchor || isExternalLink || isBlob || event.ctrlKey|| event.metaKey) { + if (newUrl === currentUrl || isAnchor || isExternalLink || isBlob || event.ctrlKey|| event.metaKey || isNewTab) { NProgress.start(); NProgress.done(); [].forEach.call(npgclass, function (el: Element) {