Skip to content

fix: restore docs sidebar access on mobile#10

Merged
roncodes merged 2 commits into
mainfrom
fix/fumadocs-mobile-sidebar
May 11, 2026
Merged

fix: restore docs sidebar access on mobile#10
roncodes merged 2 commits into
mainfrom
fix/fumadocs-mobile-sidebar

Conversation

@roncodes
Copy link
Copy Markdown
Member

Summary

  • Mobile users couldn't open the docs sidebar — no hamburger, no section picker, no page tree below the md breakpoint.
  • Root cause: every docs section layout sets nav={{ enabled: false }} on fumadocs DocsLayout (to avoid duplicating the site Navbar), which also removes fumadocs's mobile SidebarTrigger since it lives inside that disabled nav. The drawer's only built-in opener went with it.
  • Fix: a small DocsSidebarTrigger client component that uses useSidebar() from fumadocs's RootProvider context, rendered in the site Navbar's existing mobile cluster. Mounts only on /docs* and only below md (where the desktop sidebar is hidden).

Why this approach

Three options were considered:

  1. (chosen) Re-expose the trigger from the site Navbar — keeps the docs-section layouts untouched, no extra strip on mobile, uses fumadocs primitives as designed. One file changed plus one new component.
  2. Pass nav={{ component: <DocsMobileBar /> }} per docs layout — adds an extra horizontal bar and per-section editing.
  3. Floating fixed trigger from the docs root layout — works but feels less native.

Files

  • New: src/components/docs/docs-sidebar-trigger.tsx (~30 LOC client component).
  • Modified: src/components/layout/navbar.tsx — import + 1 line render slot inside the existing mobile cluster.

Verified

  • 375px (/docs): trigger visible (32×32, display:flex); click flips aria-expanded/#nd-sidebar-mobile[data-state] to open; drawer slides in with the DocsToggle section picker + 48 nav links.
  • 768px (/docs): trigger correctly display:none (md:hidden); #nd-sidebar desktop sidebar visible.
  • / (non-docs): trigger absent from SSR HTML.
  • TypeScript: no new errors introduced (pre-existing errors in *.source and api-nav.generated unchanged).

Test plan

  • Load /docs (and /docs/fleet-ops, /docs/storefront, etc.) at <768px in DevTools — confirm a panel-icon button appears between the theme toggle and the site hamburger.
  • Click it: drawer slides in from the right with the section picker at top and the current section's page tree below.
  • Pick a different section from the dropdown; pick a page link — drawer auto-closes on navigation.
  • Resize to ≥768px — trigger disappears, normal desktop sidebar takes over.
  • Visit /, /pricing, etc. — trigger does not render anywhere on non-docs routes.

Supersedes #9 (closed when its head branch was renamed from claude/beautiful-wilbur-8a2d95 to fix/fumadocs-mobile-sidebar).

🤖 Generated with Claude Code

Each docs section layout passes nav={{ enabled: false }} to fumadocs
DocsLayout to avoid duplicating the site Navbar. That also removes
fumadocs's mobile SidebarTrigger, which lived inside the disabled nav,
leaving the sidebar drawer (section picker + page tree) unreachable
below the md breakpoint.

Add a DocsSidebarTrigger client component that calls useSidebar() from
fumadocs's RootProvider context, and render it in the site Navbar's
existing mobile cluster. It only mounts on /docs routes and only at
viewports below md, where the desktop sidebar is hidden.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 10, 2026

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

Project Deployment Actions Updated (UTC)
fleetbase-io Ready Ready Preview, Comment May 11, 2026 1:47am

Request Review

Reworks the mobile nav pattern on /docs so users get one hamburger
trigger instead of two stacked icons. The site hamburger opens the
fumadocs sidebar; inside it, a "Main menu →" button overlays the site
nav drawer on top. Closing peels one layer at a time. On non-docs
routes the hamburger behaves as before.

While in there, two real bugs:

- The site drawer used to render as a child of <header>. When the
  header gets backdrop-blur (scrolled state), it establishes a new
  containing block for position:fixed descendants — the drawer's
  inset-0 collapses to the header's tiny vertical box and renders
  invisible. Drawer now portals to document.body via createPortal.

- Scroll lock used overflow:hidden on <html>, which strips
  position:sticky of its scrolling ancestor and drops the header out
  of the viewport when the menu opens after scrolling. Switched to
  overflow:clip — same lock, no scroll container established, sticky
  preserved.

Plus a 1rem top-padding rule on #nd-sidebar-mobile (banner was flush
against the header) and a small MobileNavProvider context so the
"Main menu →" button inside the docs sidebar can drive site-drawer
state from inside <main>.

Deletes the standalone DocsSidebarTrigger introduced in #9 — that
dual-icon approach is superseded by the stacked-drawer pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@roncodes roncodes mentioned this pull request May 11, 2026
@roncodes roncodes merged commit 61db7e7 into main May 11, 2026
2 checks passed
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