From 58bf7e98f6ca5a65f1e19441bf45cbd720565a26 Mon Sep 17 00:00:00 2001 From: Kea-Roy Ong <146872846+kea-roy@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:09:52 -0500 Subject: [PATCH] scroll to top on any page using saveScrollPosition if no info is saved. --- frontend/src/utils/saveScrollPosition.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/utils/saveScrollPosition.ts b/frontend/src/utils/saveScrollPosition.ts index ed4c6786..03153b7e 100644 --- a/frontend/src/utils/saveScrollPosition.ts +++ b/frontend/src/utils/saveScrollPosition.ts @@ -42,6 +42,10 @@ export const useSaveScrollPosition = (storageKey: string, pathName: string) => { } }, 16); } else { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); window.addEventListener('scroll', handleScroll); } };