From 4fb387d94ea9d7ae28a871929cbbc57e931b8d7a Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 9 Sep 2021 15:55:40 -0400 Subject: [PATCH] fix: emit prevented hashchange event --- src/client/app/router.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index c1283a424645..e769935bbf54 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -133,6 +133,8 @@ export function createRouter( // scroll between hash anchors in the same page if (hash && hash !== currentUrl.hash) { history.pushState(null, '', hash) + // still emit the event so we can listen to it in themes + window.dispatchEvent(new Event('hashchange')) // use smooth scroll when clicking on header anchor links scrollTo(link, hash, link.classList.contains('header-anchor')) }