Skip to content

Added fix: reset scroll position on route navigation#744

Open
BLOSSOM206 wants to merge 2 commits into
GitMetricsLab:mainfrom
BLOSSOM206:fix-scroll-restoration
Open

Added fix: reset scroll position on route navigation#744
BLOSSOM206 wants to merge 2 commits into
GitMetricsLab:mainfrom
BLOSSOM206:fix-scroll-restoration

Conversation

@BLOSSOM206

@BLOSSOM206 BLOSSOM206 commented Jun 15, 2026

Copy link
Copy Markdown

Related Issue


Description

This PR fixes the issue where footer navigation links could retain the previous scroll position when navigating between routes.

A reusable ScrollToTop component was added to ensure that users are automatically taken to the top of the page whenever the route changes.

Changes Made

  • Added a ScrollToTop component using useLocation and useEffect.
  • Implemented automatic scroll reset using window.scrollTo(0, 0).
  • Integrated the component into the application layout so it runs on every route change.

How Has This Been Tested?

  • Reproduced the issue locally before implementing the fix.

  • Verified that the following pages now load from the top after navigation:

    • Contact Us
    • Privacy Policy
    • About
    • Contributors
    • Tracker
  • Tested navigation through footer links.

  • Tested on desktop browser.

  • Tested using mobile device emulation in browser developer tools.

  • Confirmed the application builds and runs successfully using npm run dev.


Demonstration

Issue reproduction before the fix.

Recording.2026-06-16.031945.1.mp4

Correct scroll behavior after the fix.

github_trcker.1.mp4

Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

  • New Features
    • Automatic scroll-to-top functionality when navigating between pages, ensuring you always start at the top of new content regardless of your current UI state.

@netlify

netlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 1aaf89d
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a3076d8119a8c0009e12241
😎 Deploy Preview https://deploy-preview-744--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@BLOSSOM206, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 15 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d751e079-1301-4787-8bdb-f28e9a23585b

📥 Commits

Reviewing files that changed from the base of the PR and between ac22b93 and 1aaf89d.

📒 Files selected for processing (1)
  • src/components/ScrollToTop.tsx
📝 Walkthrough

Walkthrough

A new ScrollToTop component is added in src/components/ScrollToTop.tsx. It uses useLocation and useEffect to call window.scrollTo(0, 0) whenever location.pathname changes and renders null. It is imported and mounted unconditionally inside App.tsx.

ScrollToTop on navigation

Layer / File(s) Summary
ScrollToTop component and App wiring
src/components/ScrollToTop.tsx, src/App.tsx
ScrollToTop watches location.pathname via useEffect and calls window.scrollTo(0, 0) on each change, returning null. App.tsx imports and renders <ScrollToTop /> unconditionally in the app layout.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested labels

level:intermediate, quality:clean, gssoc:approved, type:accessibility

Poem

🐇 Hop, hop, every link I chase,
The page now starts at the topmost place!
No more landing mid-scroll in despair,
useEffect springs me right up there.
From footer links to routes anew,
Every page begins fresh — just for you! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added fix: reset scroll position on route navigation' accurately and specifically describes the main change in the PR, which is implementing a ScrollToTop component to reset scroll position when routes change.
Description check ✅ Passed The PR description comprehensively follows the template with all required sections filled: Related Issue (#743), detailed Description, thorough Testing section, Type of Change (Bug fix selected), and includes demonstration videos.
Linked Issues check ✅ Passed The PR successfully addresses the primary objective from issue #743 by implementing a ScrollToTop component that automatically resets scroll position when routes change, ensuring all pages load from the top.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to fixing the scroll position issue: adding ScrollToTop component and integrating it into App.tsx. No unrelated or out-of-scope modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you @BLOSSOM206 for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines

@BLOSSOM206

Copy link
Copy Markdown
Author

Hi @srinadhtadikonda,

This PR is ready for review. I've addressed the assigned issue, tested the changes locally, and all checks are passing.

Whenever you have time, I'd appreciate your review. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Footer navigation links do not load Contact Us and Privacy Policy pages from the top

1 participant