GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(ui): keep active sidebar item visible on navigation by codebyanas · Pull Request #9154 · nodejs/nodejs.org ConversationDescriptionFixes #8828. The sidebar's internal scroll position could leave the active navigation item outside the visible area after navigation. This change ensures that the active sidebar link is automatically scrolled into view when the pathname changes. The implementation:
TestingTested locally by navigating between sidebar pages and verifying that the active item remains visible after navigation.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new effect currently won’t re-run on locale-only route changes (locale switch keeps pathname stable), so the “active item visible” behavior can fail in that navigation path.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This PR updates the site’s sidebar wrapper to keep the currently active navigation link visible after route changes by automatically adjusting the sidebar container’s internal scrollTop when needed.
Changes:
useEffect that finds the active sidebar link after navigation and scrolls it into view if it’s outside the sidebar viewport.useScrollToElement.| File | Description |
|---|---|
| apps/site/components/withSidebar.tsx | Adds an effect that scrolls the active sidebar item into view after pathname changes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 0, | ||
| offsetTop - aside.clientHeight / 2 + active.offsetHeight / 2 | ||
| ); | ||
| }, [pathname]); |
| const active = [ | ||
| ...(aside?.querySelectorAll<HTMLAnchorElement>('a[href]') ?? []), | ||
| ].find(link => new URL(link.href).pathname === window.location.pathname); | ||
|
|
9427006a
Deployed
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Sidebar scroll position resets on navigation, active item can be off-screen
There was an error while loading. Please reload this page.