From 7bb3a4863772cb48694e28df00945e63ce76f61c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 1 Apr 2021 15:43:57 +0200 Subject: [PATCH] fix(scroll): always scroll to hash --- src/client/app/router.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 94077870..01637b53 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -132,10 +132,16 @@ export function createRouter( e.preventDefault() if (pathname === currentUrl.pathname) { // scroll between hash anchors in the same page - if (hash && hash !== currentUrl.hash) { - history.pushState(null, '', hash) + if (hash) { + if (hash !== currentUrl.hash) { + history.pushState(null, '', hash) + } // use smooth scroll when clicking on header anchor links - scrollTo(link, hash, link.classList.contains('header-anchor')) + scrollTo( + link, + decodeURIComponent(hash), + link.classList.contains('header-anchor') + ) } } else { go(href)