Bug: No scroll-to-top on route navigation #89

Closed
opened 2026-05-17 21:15:17 -05:00 by null · 0 comments
Owner

Problem

When navigating between pages (e.g. from Services to Contact), the scroll position persists from the previous page. Users land mid-page instead of at the top.

This is a known SPA issue - React Router does not auto-scroll on route change.

Fix

Add a ScrollToTop component that calls window.scrollTo(0, 0) on every route change:

import { useEffect } from react;
import { useLocation } from react-router-dom;
export default function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => { window.scrollTo(0, 0); }, [pathname]);
return null;
}

Then add ScrollToTop inside the App component.

Files

  • src/components/ScrollToTop.jsx - new
  • src/App.jsx - import and render

Severity

Medium - affects all page transitions

## Problem When navigating between pages (e.g. from Services to Contact), the scroll position persists from the previous page. Users land mid-page instead of at the top. This is a known SPA issue - React Router does not auto-scroll on route change. ## Fix Add a ScrollToTop component that calls window.scrollTo(0, 0) on every route change: import { useEffect } from react; import { useLocation } from react-router-dom; export default function ScrollToTop() { const { pathname } = useLocation(); useEffect(() => { window.scrollTo(0, 0); }, [pathname]); return null; } Then add ScrollToTop inside the App component. ## Files - src/components/ScrollToTop.jsx - new - src/App.jsx - import and render ## Severity Medium - affects all page transitions
null closed this issue 2026-05-17 21:38:10 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: null/Queue-North-Website#89
No description provided.