Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe following codeowners have been identified for the changed files: Team reviewers: @nodejs/nodejs-website Please review the changes when you have a chance. Thank you! 🙏 |
cf5514a to
87d5232
Compare
…pper doc-kit targets `is-land[data-island-name='SideBar']` while this repo registers the island as `Sidebar`, leaving it with `display: contents` and breaking sticky/overflow scrolling on the sidebar.
|
I actually quite like the active menu item coming into view |
| return; | ||
| } | ||
|
|
||
| console.log(pathname); |
There was a problem hiding this comment.
| console.log(pathname); |
| rel="canonical" | ||
| href="https://nodejs.org/learn${metadata.path.replace('/index', '')}" | ||
| /> | ||
| <style> |
There was a problem hiding this comment.
Doc-kit already provides sidebar styling, but it targets an island named SideBar, whereas this one is is registered as Sidebar. So I'm wondering if we could update the island name to match and remove this style block?
That should also fix the sidebar height so it accounts for the header. I noticed in the preview that sometimes an active item sitting just below the viewport doesn't get scrolled into view
There was a problem hiding this comment.
Good catch! I've updated the island name to SideBar (matching both doc-kit.config.mjs, withIsland, and the e2e test) and removed the custom <style> block from template.html.
Relying on doc-kit's native styling fixed the container height properly and resolved the issue where active items near the bottom of the viewport weren't scrolled into view.
Ready for another look!
Every navigation on https://nodejs.org/learn
is a full page load, so the sidebar always resets to the top. When you click an item near the bottom of the sidebar (e.g. Diagnostics or TypeScript), the page you just opened is no longer visible in the navigation, and you have to scroll back down to find where you are.
This PR scrolls the sidebar so the active item is centered when the page loads.
Earlier ideas were discussed and turned down:
This approach needs no storage and no navigation changes. The active item is derived from the current pathname, which the sidebar already knows. The whole change is limited to components/Sidebar/index.jsx.
Changes
components/Sidebar/index.jsx: adds a useLayoutEffect that:
Validation