Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: scroll to top on SPA navigation in demo site#163

Merged
twschiller merged 1 commit into
mainfrom
fix/demo-spa-scroll-restore
Jun 5, 2026
Merged

Fix: scroll to top on SPA navigation in demo site#163
twschiller merged 1 commit into
mainfrom
fix/demo-spa-scroll-restore

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • Clicking the brand logo from a scrolled product detail page updated the URL and re-rendered the Home route, but BrowserRouter preserved the scroll position — the user landed mid-page on Home and the hero never came into view, so it looked like nothing changed.
  • Added a useLayoutEffect keyed on pathname in App that scrolls to top on every SPA navigation.

Test plan

  • bun run check passes
  • Manually verified: scroll a product detail page down ~1500px, click the RiverMart logo — Home now renders at scroll 0 with the "Spring Refresh Sale" hero in view.
  • Verified routing still works from / to product detail and back via Playwright.

🤖 Generated with Claude Code

Clicking the brand logo from mid-page on a product detail updated the
URL and rendered the Home page, but BrowserRouter preserved the scroll
position — so the user landed in the middle of the new page and the
hero never came into view, making it look like nothing changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 2:05pm

Request Review

@twschiller twschiller added the bug Something isn't working label Jun 5, 2026
@twschiller twschiller merged commit 0a77c68 into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the fix/demo-spa-scroll-restore branch June 5, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant