Merged in fix/SW-3026-prod---users-are-not-focused-on- (pull request #2379)

fix: SW-3026 Fixed scroll issue

* fix: SW-3026 Fixed scroll issue

* fix: SW-3026 Moved to global solution for scroll to top after page navigation


Approved-by: Tobias Johansson
Approved-by: Linus Flood
This commit is contained in:
Hrishikesh Vaipurkar
2025-06-18 12:27:58 +00:00
parent 846fd904a6
commit 64a56b7050
6 changed files with 16 additions and 11 deletions

View File

@@ -9,7 +9,7 @@ import useTrackingStore from "@/stores/tracking"
import useLang from "@/hooks/useLang"
import { trackPageViewStart } from "@/utils/tracking"
export default function RouterTracking() {
export default function RouteChange() {
const pathName = usePathname()
const searchParams = useSearchParams()
const currentLang = useLang()
@@ -28,6 +28,11 @@ export default function RouterTracking() {
return
}
if (hasPathOrLangChanged()) {
// Scroll to top on page load whenever page is navigated to new URL (page)
window.scrollTo({ top: 0, left: 0, behavior: "instant" })
}
updateRouteInfo(pathName, currentLang, searchParams)
if (hasPathOrLangChanged() || hasBookingFlowParamsChanged()) {
setInitialPageLoadTime(Date.now())