From efc2dbac3b6fadbe099af3f28df765e455a76577 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Wed, 25 Oct 2023 15:48:33 -0300 Subject: [PATCH] fix(storefront): Update `` to skip /app/* routes and dont prefetch with role=button `` commonly used as no-JS interaction fallback, thus, on-click redirect may be prevented after component hydration. Should not prefetch. /app/* are "real" SPA routes, ensure not prefecthing and forcing reload --- .../storefront/src/lib/components/ViewTransitions.astro | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/storefront/src/lib/components/ViewTransitions.astro b/packages/storefront/src/lib/components/ViewTransitions.astro index 24c86ef28..970bb766e 100644 --- a/packages/storefront/src/lib/components/ViewTransitions.astro +++ b/packages/storefront/src/lib/components/ViewTransitions.astro @@ -305,6 +305,7 @@ const { fallback = 'animate' } = Astro.props as Props; link.dataset.astroReload !== undefined || link.hasAttribute('download') || !link.href || + link.pathname.startsWith('/app/') || // "real" SPA routes (link.target && link.target !== '_self') || link.origin !== location.origin || ev.button !== 0 || // left clicks only @@ -384,8 +385,13 @@ const { fallback = 'animate' } = Astro.props as Props; if ( el.origin === location.origin && el.pathname !== location.pathname && + !el.pathname.startsWith('/app/') && // "real" SPA routes el.dataset.astroReload === undefined && !el.hasAttribute('download') && + /* commonly used as no-JS interaction fallback, + thus, on-click redirect may be prevented after component hydration. + Shouldn't prefetch. */ + el.role !== 'button' && transitionEnabledOnThisPage() ) { maybePrefetch(el.pathname);