From 60fc8fd24460eede1dc73768ad0aa53616da746f Mon Sep 17 00:00:00 2001 From: DY_XiaoDong Date: Wed, 22 Nov 2023 18:19:52 +0800 Subject: [PATCH] fix(client): no onAfterRouteChanged called after popstate (#3227) closes #3226 --- src/client/app/router.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 6e4f0774..3a7d8cb5 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -222,11 +222,12 @@ export function createRouter( { capture: true } ) - window.addEventListener('popstate', (e) => { - loadPage( + window.addEventListener('popstate', async (e) => { + await loadPage( normalizeHref(location.href), (e.state && e.state.scrollPosition) || 0 ) + router.onAfterRouteChanged?.(location.href) }) window.addEventListener('hashchange', (e) => {