Skip to content

fix: stabilize scrollbar gutter to stop layout shifting between pages#209

Merged
mirzakopic merged 1 commit into
mainfrom
fix/layout-issue
May 25, 2026
Merged

fix: stabilize scrollbar gutter to stop layout shifting between pages#209
mirzakopic merged 1 commit into
mainfrom
fix/layout-issue

Conversation

@mirzakopic

Copy link
Copy Markdown
Contributor

What

Fixes the content and navbar shifting horizontally ("jumping") by a few millimetres when navigating between documentation pages.

Root causes

Two distinct causes, both surfacing on browsers that reserve scrollbar space (e.g. macOS "Show scroll bars: Always", common on external/ultra-wide monitors):

  1. Page-to-page shift (all pages). The whole page scrolls on <html> and the layout is centered within --vp-layout-max-width. Pages whose content overflows show a vertical scrollbar; pages that fit don't. That ~15px width change re-centers everything, so the logo, nav and content column shift between a scrolling and a non-scrolling page (e.g. /reference/ vs /concepts/).

  2. Home ↔ menu-page shift (version selector / right-hand nav). VitePress positions sidebar-page navbars and content with 100vw-based padding (gutter-inclusive), while the home navbar centers via 100% (gutter-aware). With the gutter reserved, the two differ by half a scrollbar width, so the version selector and right nav items jump when moving between the home page and any menu page.

Fix

All in .vitepress/theme/custom.css:

  • html { scrollbar-gutter: stable } — reserve the gutter on every page so it never toggles.
  • A @media (min-width: 1440px) block recomputing the sidebar-page navbar/content paddings with 100% instead of 100vw, so internal pages are gutter-aware and line up with the home page. max() floors the values so narrow viewports fall back to VitePress defaults.

No-op on overlay-scrollbar systems (which never had the jump).

Verification

Measured with headless Chrome against the dev server:

  • All 71 doc pages + home share an identical logo position — no page-to-page shift.
  • Version selector / GitHub icon / outline-column right edges align across home + all six menu pages at 1920px and 3440px (ultra-wide).
  • The navbar now also aligns with each doc page's "On this page" outline; incidentally corrects a pre-existing misalignment in the 1440–1536px range.
  • Full 85-route crawl: 0 missing/404; redirect stubs serve 200.

🤖 Generated with Claude Code

On-behalf-of: @SAP mirza.kopic@sap.com
Signed-off-by: Mirza Kopić <mirza.kopic@gmail.com>
@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-05-25 08:37 UTC

@mirzakopic mirzakopic merged commit 711ef5f into main May 25, 2026
5 checks passed
@mirzakopic mirzakopic deleted the fix/layout-issue branch May 25, 2026 08:36
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.

2 participants