Skip to content

Commit eac65c9

Browse files
committed
fix(docs): stop the sidebar drifting when page content resizes
The sidebar used fumadocs' `sticky` positioning, and a sticky box is bottom-limited by its containing block. #nd-docs-layout ends ~660px above the document bottom because the site footer is a sibling of the layout rather than a grid child, so across the whole footer the sidebar was pushed progressively upward. Any content-height change while the reader sat in that zone then moved it: expanding one FAQ row shifted the sidebar 16.8px at a fixed scroll offset, and collapsing it shifted it back. Pin the sidebar and its divider to the viewport instead. A fixed box ignores both the container's end and the document height, so neither the drift nor the jump can happen. The grid columns are explicit (`0px 300px 1fr 268px 0px`), so taking the placeholder out of flow leaves its track intact and the content column does not move. The footer is already opaque and now out-stacks both, so it slides over them at the end of the page. Measured with Playwright before and after: sidebar delta on expand/collapse 16.8px/-16.8px -> 0px/0px, content column left and width unchanged, and the sidebar holds top:92px at the page bottom on the docs, API-reference, academy and integrations layouts. Mobile is untouched (the rule is desktop-only).
1 parent 2ba2484 commit eac65c9

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

apps/docs/app/global.css

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,33 @@ aside#nd-sidebar [data-radix-scroll-area-viewport] {
362362
min-height: var(--fd-docs-height) !important;
363363
}
364364

365-
/* Sidebar divider line — sticky within the docs layout box, so it ends where
366-
the layout does instead of bleeding into (or past) the footer below it.
367-
#nd-docs-layout is a CSS grid (see fumadocs' Container slot); a sticky
368-
pseudo-element stays in normal flow, so without an explicit grid-area it
369-
gets auto-placed into a real content cell and skews that cell's sizing.
370-
Spanning the full grid keeps it purely decorative/overlaid instead. */
365+
/* Pin the sidebar to the viewport instead of letting fumadocs' `sticky` do it.
366+
A sticky box is bottom-limited by its containing block, and #nd-docs-layout
367+
ends ~660px above the document bottom because the site footer is a sibling
368+
of the layout, not a grid child. So across the whole footer the sidebar gets
369+
pushed upward — and any content-height change while the reader is in that
370+
zone (expanding an FAQ row, say) makes it visibly jump. A fixed box ignores
371+
both the container's end and the document's height, so neither happens.
372+
373+
Safe because the grid columns are explicit (`0px 300px 1fr 268px 0px`), so
374+
removing the placeholder from flow leaves its track intact. `left`/`width`
375+
are restated because a fixed box no longer derives them from its grid cell,
376+
and `top`/`height` already come from fumadocs' own utility classes. */
377+
[data-sidebar-placeholder] {
378+
position: fixed !important;
379+
left: var(--sidebar-offset);
380+
width: var(--fd-sidebar-width);
381+
}
382+
383+
/* Sidebar divider line — pinned for the same reason, and to stay glued to the
384+
sidebar's right edge. #nd-docs-layout is a CSS grid (see fumadocs' Container
385+
slot); the pseudo-element spans the full grid so it reads as decorative
386+
overlay rather than being auto-placed into a real content cell and skewing
387+
that cell's sizing. */
371388
#nd-docs-layout::before {
372389
content: "";
373390
display: block;
374-
position: sticky;
391+
position: fixed;
375392
grid-row: 1 / -1;
376393
grid-column: 1 / -1;
377394
top: 92px; /* below navbar */
@@ -383,6 +400,14 @@ aside#nd-sidebar [data-radix-scroll-area-viewport] {
383400
z-index: 21;
384401
}
385402

403+
/* The footer is opaque and now has to out-stack the pinned sidebar and its
404+
divider (z-index 20 and 21), so it slides over them at the end of the page
405+
rather than being drawn through. */
406+
footer {
407+
position: relative;
408+
z-index: 22;
409+
}
410+
386411
/* Hide fumadocs nav on desktop - we use custom navbar there */
387412
#nd-docs-layout > header {
388413
display: none !important;

0 commit comments

Comments
 (0)