Skip to content

Fix mobile header: restore close icon, remove empty top bar, lock scroll, prevent layout shift#18612

Open
dwahbe wants to merge 1 commit intopulumi:masterfrom
dwahbe:fix/mobile-header-nav
Open

Fix mobile header: restore close icon, remove empty top bar, lock scroll, prevent layout shift#18612
dwahbe wants to merge 1 commit intopulumi:masterfrom
dwahbe:fix/mobile-header-nav

Conversation

@dwahbe
Copy link
Copy Markdown

@dwahbe dwahbe commented Apr 20, 2026

Proposed changes

Four small, related fixes to the mobile site header, touching layouts/partials/header.html, theme/src/scss/_header.scss, and theme/src/ts/misc.ts.

  • Restore the close (X) icon when the burger menu is open. The open-state <label> carried the Tailwind hidden class. Tailwind v4 puts .hidden in the utilities layer, which beats the display: block override in the components layer regardless of selector specificity, so the X never rendered. Removed hidden from the markup and replaced @apply hidden/block with plain display: none/block so the toggle override stays in the same layer as its default.

Before
Screenshot 2026-04-20 at 5 07 25 PM

After
Screenshot 2026-04-20 at 5 06 47 PM

  • Remove ~32px of empty space above the header on mobile. The .top-nav-bar wraps its desktop-only links UL in a <div class="w-full p-4">. On mobile the UL is hidden, but the wrapper's 16px top+bottom padding still reserves 32px. Added hidden lg:block so the wrapper only takes space at the breakpoint where its content is visible.

Before
Screenshot 2026-04-20 at 5 08 24 PM

After
Screenshot 2026-04-20 at 5 08 54 PM

  • Lock body scroll while the mobile menu is open. Previously the page behind the menu could still scroll. Added html:has(.mobile-menu-toggle:checked) { overflow: hidden }. Because overflow: hidden on <html> breaks position: sticky, the rule also pins .header-container with position: fixed while the menu is open so it stays in the viewport regardless of scroll position.

  • Prevent a 1px layout shift when opening the menu. The header's sticky uses top: -1px for IntersectionObserver-based pinned-state detection. When the menu opens, the header grows to 100vh and the IO fired and added is-pinned, which shifted the fixed header up by 1px. The observer now early-returns when the mobile menu toggle is checked, so is-pinned doesn't flip based on menu state.

…oll, prevent layout shift

- Drop Tailwind `hidden` from the menu open-state label and switch the toggle
  override to plain `display` so the rule stays in the components layer
  (Tailwind v4 utilities layer was beating the override).
- Add `hidden lg:block` to the desktop-only links wrapper so its `p-4`
  doesn't reserve 32px of empty space on mobile.
- Lock html overflow while the mobile menu is open and pin the header with
  `position: fixed` (sticky degrades when html overflow is hidden).
- Have the header IntersectionObserver early-return while the menu is open so
  the menu-induced height change doesn't toggle `is-pinned` and shift the
  header by 1px.

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

@CamSoper CamSoper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dwahbe -- the writeup made this easy to review. Approving from the docs side. Tagging @cnunciato and @jeffmerrick for a second look since this touches the homepage header.

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