Skip to content

fix: collapse docs navbar into hamburger when it overflows#1117

Open
dkrizan wants to merge 2 commits into
mainfrom
dkrizan/fix-docs-navbar-overflow
Open

fix: collapse docs navbar into hamburger when it overflows#1117
dkrizan wants to merge 2 commits into
mainfrom
dkrizan/fix-docs-navbar-overflow

Conversation

@dkrizan

@dkrizan dkrizan commented Jun 9, 2026

Copy link
Copy Markdown
Member

Problem

On a range of intermediate widths (roughly 1000–1320px) the docs header rendered broken: the navigation labels (e.g. "JavaScript SDK") wrapped to two lines and the "Tolgee" wordmark was ellipsis-truncated to "Tolg…".

The full desktop navbar — logo, wordmark, GitHub stars, all section links, Login/Sign up and search — only fits around 1320px, but Docusaurus only collapses into the hamburger drawer below its hardcoded 996px breakpoint. The ~320px band in between had no room, so flex children shrank and wrapped.

Fix

Extend the existing hamburger mechanism upward instead of shrinking the bar:

  • ≥ 1320px — full bar (logo + wordmark + GitHub stars + all links + Login/Sign up + Search + theme toggle).
  • < 1320px (down to phones) — logo, wordmark and GitHub stars stay visible; the navigation links collapse into the native hamburger drawer.

This reuses the existing slide-in drawer (consistent UX, including the per-page doc-sidebar integration) with no dependency patching.

Changes

  • src/component/navbar/useNavbarCollapsed.ts (new)matchMedia hook exporting the single source of truth NAVBAR_COLLAPSE_QUERY.
  • src/theme/Navbar/MobileSidebar/index.tsx (new swizzle) — renders the native drawer whenever the navbar is collapsed (or already open), not only below 996px.
  • src/theme/Navbar/Content/index.tsx — GitHub button always rendered (was hidden xl:flex); effect closes the drawer if the viewport widens past the breakpoint while open.
  • src/css/custom.css — GitHub button always visible; below 1320px show the toggle and hide the inline navbar links (extends Infima's 996px rule).
  • src/theme/Navbar/Content/styles.module.css — theme toggle hidden in the bar below the breakpoint (it lives in the drawer header there).

Testing

Verified live in the browser at 1320 (full bar), 1319 (collapsed), 1184, and 390px, including opening the hamburger drawer and confirming all links are present. ESLint and tsc pass for the changed files.

Note

Keeping logo + wordmark + GitHub stars always visible and requiring the full nav to fit means common 1280px laptops now show the hamburger — an intentional consequence of the desired behavior.

The desktop navbar (logo, wordmark, GitHub stars, all section links,
Login/Sign up and search) only fits around 1320px, but Docusaurus only
collapses into the hamburger drawer below its hardcoded 996px breakpoint.
In the ~1000-1320px band the links wrapped to two lines and the wordmark
was ellipsis-truncated.

Extend the existing hamburger mechanism up to 1320px: keep the logo,
wordmark and GitHub stars visible at every width, and collapse the
navigation links into the native drawer below 1320px. The drawer is
reused by relaxing its render gate (swizzled Navbar/MobileSidebar) and a
shared useNavbarCollapsed media-query hook; no dependency patching.
@dkrizan dkrizan force-pushed the dkrizan/fix-docs-navbar-overflow branch from 44e96f1 to 74c9738 Compare June 9, 2026 15:15
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for tolgee-docs ready!

Name Link
🔨 Latest commit 44e96f1
🔍 Latest deploy log https://app.netlify.com/projects/tolgee-docs/deploys/6a282d3cda6f2800082c5f51
😎 Deploy Preview https://deploy-preview-1117--tolgee-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for tolgee-docs ready!

Name Link
🔨 Latest commit bb329d9
🔍 Latest deploy log https://app.netlify.com/projects/tolgee-docs/deploys/6a28415764a3ae0008f9fc91
😎 Deploy Preview https://deploy-preview-1117--tolgee-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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