From 997a74df442dad8601c824729b78a6beb270619c Mon Sep 17 00:00:00 2001 From: scarf Date: Mon, 11 Mar 2024 09:22:15 +0900 Subject: [PATCH] fix: fragments not adding history --- lib/handlers.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/handlers.ts b/lib/handlers.ts index 738ead4..7a4370b 100644 --- a/lib/handlers.ts +++ b/lib/handlers.ts @@ -92,18 +92,18 @@ export function handleLinkClick(e: MouseEvent): RouteChangeData { // Start router takeover e.preventDefault(); + // ID to scroll to after navigation, like /route/#some-id + const scrollId = ahref.match(/#([\w'-]+)\b/g)?.[0]; + const next = fullURL(url.href); + const prev = fullURL(); + addToPushState(next); + // If anchor, scroll, if (ahref?.startsWith('#')) { scrollToAnchor(ahref); return { type: 'scrolled' }; } - // ID to scroll to after navigation, like /route/#some-id - const scrollId = ahref.match(/#([\w'-]+)\b/g)?.[0]; - const next = fullURL(url.href); - const prev = fullURL(); - - // addToPushState(next); return { type: 'link', next, prev, scrollId }; } else { return { type: 'noop' };