Skip to content

docs: stop sidebar jump and make scroll instant#161

Open
jayhack wants to merge 2 commits into
developfrom
docs/sidebar-stability
Open

docs: stop sidebar jump and make scroll instant#161
jayhack wants to merge 2 commits into
developfrom
docs/sidebar-stability

Conversation

@jayhack

@jayhack jayhack commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two docs-site annoyances reported after #160:

  • Sidebar jumps when clicking a link. The docs route had no shared layout — app/docs/[[...slug]]/page.tsx rendered the header + sidebar + content itself, so every navigation re-mounted the sidebar and reset its scroll position. I moved the header and sidebar into a persistent app/docs/layout.tsx, and made the sidebar a client component (components/docs-sidebar.tsx) that derives the active item from usePathname(). The sidebar now stays mounted across navigations, preserving scroll and active state without a jump.
  • Scroll-to-top was animated. Switched scroll-behavior: smoothauto in globals.css so scroll-to-top (and in-page anchor jumps) are instantaneous.

Also added scrollbar-gutter: stable so pages of different heights don't cause a horizontal shift when the viewport scrollbar appears/disappears (another source of the sidebar "moving").

Changes

  • site/app/docs/layout.tsx (new): persistent header + sidebar shell + mobile menu.
  • site/components/docs-sidebar.tsx (new): client sidebar nav using usePathname() for active highlighting.
  • site/app/docs/[[...slug]]/page.tsx: reduced to just the article + TOC (header/sidebar moved to the layout).
  • site/app/globals.css: scroll-behavior: auto + scrollbar-gutter: stable.

Test plan

  • npm run build in site/ passes (TypeScript + 287 static pages).
  • Click between sidebar links and confirm the sidebar no longer jumps and keeps its scroll position.
  • Confirm scroll-to-top on navigation and TOC anchor clicks are instant (no animation).

Made with Cursor

Move the docs header and sidebar into a persistent app/docs/layout.tsx so
they no longer re-mount on every navigation. The sidebar is now a client
component that derives the active item from usePathname(), which preserves
its scroll position and stops the visible jump when clicking links.

Also reserve the scrollbar gutter (scrollbar-gutter: stable) to prevent
horizontal layout shift between pages of different heights, and switch
scroll-behavior from smooth to auto so scroll-to-top is instantaneous.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jayhack jayhack requested a review from a team as a code owner June 23, 2026 15:42
@jayhack jayhack requested review from kopekC and removed request for a team June 23, 2026 15:42
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
graph-sitter Ready Ready Preview, Comment Jun 23, 2026 3:44pm

Request Review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant