From ac22b93f5a67a82d5dc016aabeb2c66a3e78eab3 Mon Sep 17 00:00:00 2001 From: Blossom Fernandes Date: Tue, 16 Jun 2026 03:06:57 +0530 Subject: [PATCH 1/2] Added fix: reset scroll position on route navigation --- src/App.tsx | 2 ++ src/components/ScrollToTop.tsx | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/components/ScrollToTop.tsx diff --git a/src/App.tsx b/src/App.tsx index 8eafb448..cada3b21 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,7 @@ import Footer from "./components/Footer"; import ScrollProgressBar from "./components/ScrollProgressBar"; import { Toaster } from "react-hot-toast"; import Router from "./Routes/Router"; +import ScrollToTop from "./components/ScrollToTop"; const FULLSCREEN_ROUTES = ["/signup", "/login"]; @@ -13,6 +14,7 @@ function App() { return (
+ {!isFullscreen && } {!isFullscreen && } diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx new file mode 100644 index 00000000..ce14cf45 --- /dev/null +++ b/src/components/ScrollToTop.tsx @@ -0,0 +1,12 @@ +import {useEffect} from 'react'; +import {useLocation} from 'react-router-dom'; + +function ScrollToTop() { + const location = useLocation(); + useEffect(() => { + window.scrollTo(0, 0); + },[location.pathname]); + + return null; +} +export default ScrollToTop; \ No newline at end of file From 1aaf89d443b1762a4771eb930292831eba7fd96b Mon Sep 17 00:00:00 2001 From: Blossom Fernandes Date: Tue, 16 Jun 2026 03:33:51 +0530 Subject: [PATCH 2/2] docs: add docstring for ScrollToTop component --- src/components/ScrollToTop.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx index ce14cf45..15f6d95b 100644 --- a/src/components/ScrollToTop.tsx +++ b/src/components/ScrollToTop.tsx @@ -1,6 +1,9 @@ import {useEffect} from 'react'; import {useLocation} from 'react-router-dom'; - +/** + * Resets the window scroll position to the top + * whenever the route pathname changes. + */ function ScrollToTop() { const location = useLocation(); useEffect(() => {