From 504cf50f9a9053c7e3fbc8cdc2598dc44ede8c35 Mon Sep 17 00:00:00 2001 From: Rajath Venkatesh Date: Wed, 3 Jan 2024 21:46:17 +0530 Subject: [PATCH] Using the latest value of the location pathname and location search to fix the browser back button forward issue --- libs/mf-tools/src/lib/web-components/router-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/mf-tools/src/lib/web-components/router-utils.ts b/libs/mf-tools/src/lib/web-components/router-utils.ts index 2fea414d..911233b4 100644 --- a/libs/mf-tools/src/lib/web-components/router-utils.ts +++ b/libs/mf-tools/src/lib/web-components/router-utils.ts @@ -26,13 +26,13 @@ export function connectRouter(router: Router, useHash = false): void { url = `${location.pathname.substring(1)}${location.search}`; router.navigateByUrl(url); window.addEventListener('popstate', () => { - router.navigateByUrl(url); + router.navigateByUrl(`${location.pathname.substring(1)}${location.search}`); }); } else { url = `${location.hash.substring(1)}${location.search}`; router.navigateByUrl(url); window.addEventListener('hashchange', () => { - router.navigateByUrl(url); + router.navigateByUrl(`${location.pathname.substring(1)}${location.search}`); }); } }