fix(docsite): present SideNav family Overview preview at intrinsic height#3577
fix(docsite): present SideNav family Overview preview at intrinsic height#3577cixzhang wants to merge 2 commits into
Conversation
The Overview preview box uses a fixed 16/9 aspect ratio with align-items: center. The SideNav family is a full-height sidebar (height: 100%), so it stretches to fill the box and reads as top-aligned with an empty gap below. Give the full-height family an auto-height, top-anchored container so height: 100% resolves to auto (content-sized) and the sidebar presents as built. All other components keep the centered 16/9 tile.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This isn't the right fix. Sidenav is intended to span the height of the container. Maybe the best thing to do is to give the sidenav showcase a clear container like a card and give the container a reasonable height inside the showcase, potentially allowing for scroll like the toolbar showcase. We could also include some footer items in the showcase so there's better containment. |
|
Understood — you're right that special-casing the SideNav family in Your proposed direction makes sense to me, so to confirm the plan before I rework it:
One open question: this only naturally covers the Happy to implement once you confirm the container height/scroll and whether to extend it to the sibling showcases. |
|
Let's keep it consistent for the family of side nav showcases. The examples should likely avoid the extra container though since we don't want to promote the use of card with side nav. Maybe a better container to use would be AppShell with mobile nav disabled. |
Address review: drop the ShowcasePreview special-casing that top-anchored the SideNav family at intrinsic height (SideNav is meant to span its container). Instead give each family showcase (SideNav, SideNavItem, SideNavSection, SideNavCollapseButton, SideNavHeading) a real full-height container by wrapping it in an AppShell with mobile nav disabled, plus footer/support items so the rail reads as properly contained top-to-bottom. Revert ShowcasePreview to its prior generic behavior.
|
Done in 95f378b. Reverted the Each SideNav family showcase (SideNav, SideNavItem, SideNavSection, SideNavCollapseButton, SideNavHeading) is now wrapped in an SideNavHeading was the one edge case — it compares two heading configs, so I rendered it as two side-by-side AppShells (each Docsite typechecks clean against the family showcases and the data-extraction suite passes. Worth an eyeball in the docsite preview to confirm the AppShell fills the ratio box the way you're picturing. |
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Problem
On the component Overview tab, the SideNav family renders top-aligned with a
large empty gap below — it looks broken rather than centered/sized as built.
Affects the shared family:
Root cause
ShowcasePreviewrenders the Overview preview inside a flex box with a fixedaspect-ratio: 16 / 9andalign-items: center. That works forcontent-sized components, but the SideNav root is a full-height sidebar
(
display: flex; flex-direction: column; height: 100%) with an innerflex: 1scroll region.Because the preview box has a definite height (from the aspect ratio), the
sidebar's
height: 100%resolves against it and stretches to fill the box.align-items: centeris a no-op once the child already spans the full height.Inside the sidebar, the header/sections sit at the top and the
flex: 1regionexpands into the remaining space — so the content reads as "pinned to the top"
with an empty gap below. This is the reported appearance; it is not how a real
sidebar (which fills a viewport-height rail) is meant to look in a short,
wide preview tile.
Fix
Treat the SideNav family as full-height in the preview and present it at its
intrinsic height, top-anchored instead of stretched-and-centered:
maxHeightcap) instead of thefixed
aspect-ratio. With an indefinite container height, the sidebar'sheight: 100%computes toauto→ the sidebar is content-sized, so there isno empty gap.
align-items: flex-start, matching how a sidebar reads (top-down).This is the smallest correct change and keeps
align-items: center+aspect-ratio: 16 / 9for every other component. The existing SideNav-onlyonClickCaptureguard is generalized to the whole family in the same place.Validation
Chosen method: typecheck + lint + existing preview test suite + a documented
docsite eyeball — not a bespoke string-pinning test. The bug is a pure
flexbox layout issue in the preview container; there is no untested code
behavior that warrants a new assertion, and the fix's correctness is a rendered
result best confirmed visually.
apps/docsitetypecheck: no errors in the changed file.component-preview-state,component-preview-theme):15/15 pass — no regression.
height: 100%flex child fills adefinite-height container regardless of
align-items, and resolves toautounder an indefinite-height container.
What to eyeball in the docsite (Overview tab): open Side Nav, Side Nav Item,
Side Nav Section, and Side Nav Collapse Button. The sidebar should sit snug in
the preview at its natural height (no large empty area below), anchored to the
top. Confirm all other components' Overview previews are unchanged (still
centered in a 16:9 tile).
Closes #2703