Skip to content

fix(topnav): mega menu backdrop no longer covers nav items - #377

Merged
rubyycheung merged 1 commit into
mainfrom
navi/fix/megamenu-backdrop-covers-nav
Feb 27, 2026
Merged

rubyycheung merged 1 commit into
mainfrom
navi/fix/megamenu-backdrop-covers-nav

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Problem

The XDSTopNavMegaMenu backdrop div (z-index: 99) visually covers the nav bar items when the mega menu opens. The backdrop creates a unified card appearance by overlaying the entire positioned ancestor, but the nav items have no z-index and render behind it — making them invisible.

Fix

Added position: relative and zIndex: 100 to the XDSTopNav base style. This creates a stacking context for the nav bar so its content renders above the backdrop (99) while the mega menu panel (100, later in DOM order) still paints on top.

Test Plan

  • Added unit test verifying the nav element has position: relative and z-index >= 100
  • All 1056 existing tests pass
  • Lint clean, build clean

The XDSTopNavMegaMenu backdrop (z-index 99) visually covered nav bar
items since they had no stacking context. Added position: relative and
zIndex: 100 to XDSTopNav base style so nav content renders above the
backdrop while the mega menu panel still paints on top.

Co-authored-by: Navi <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 27, 2026
@rubyycheung
rubyycheung added this pull request to the merge queue Feb 27, 2026
@github-actions

github-actions Bot commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

TopNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 383B N/A
Lines of Code N/A 924 -
Complexity N/A Very High (49) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 8.0KB 13.0KB 2.0KB

Accessibility Audit

Status: No accessibility violations detected.

Component Previews

Includes interactive hover previews as animated GIFs.

XDSTopNav

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · navigation-xdstopnav--default

With Logo

Screenshot:

With Logo

View in Storybook · navigation-xdstopnav--with-logo

Title Only

Screenshot:

Title Only

View in Storybook · navigation-xdstopnav--title-only

Nav Item States

Screenshot:

Nav Item States

View in Storybook · navigation-xdstopnav--nav-item-states

Centered Navigation

Screenshot:

Centered Navigation

View in Storybook · navigation-xdstopnav--centered-navigation

Centered With Start Content

Screenshot:

Centered With Start Content

View in Storybook · navigation-xdstopnav--centered-with-start-content

Center Content Without End

Screenshot:

Center Content Without End

View in Storybook · navigation-xdstopnav--center-content-without-end

Full Example

Screenshot:

Full Example

View in Storybook · navigation-xdstopnav--full-example


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Merged via the queue into main with commit 1a8ce19 Feb 27, 2026
10 checks passed
rubyycheung added a commit that referenced this pull request Feb 27, 2026
…ment

PR #377 incorrectly added position:relative + z-index to the <nav>
element, which made it the positioned ancestor for the MegaMenu
backdrop — breaking the unified card visual. The correct fix is to
add the stacking context to the nav's content sections (leftSection,
centerContent, rightSection, endContent) so they sit above the
backdrop (z-index 99) while the backdrop still positions relative
to the outer wrapper.

Co-authored-by: Navi <[email protected]>
rubyycheung added a commit that referenced this pull request Feb 27, 2026
The MegaMenu backdrop div was intended to create a unified card
appearance by overlaying the nav area with a white background,
shadow, and rounded corners. However, because the backdrop lives
inside the nav DOM tree, it inevitably covers the nav items
regardless of z-index workarounds.

Removed the backdrop entirely. The unified card look is achieved by:
- The navWrapper providing top rounded corners and shadow
- The panel providing bottom rounded corners and its own shadow

Also reverted the stacking context workarounds from #377 that were
added to XDSTopNav sections (no longer needed without the backdrop).

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
The XDSTopNavMegaMenu backdrop (z-index 99) visually covered nav bar
items since they had no stacking context. Added position: relative and
zIndex: 100 to XDSTopNav base style so nav content renders above the
backdrop while the mega menu panel still paints on top.

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
…ment (#378)

PR #377 incorrectly added position:relative + z-index to the <nav>
element, which made it the positioned ancestor for the MegaMenu
backdrop — breaking the unified card visual. The correct fix is to
add the stacking context to the nav's content sections (leftSection,
centerContent, rightSection, endContent) so they sit above the
backdrop (z-index 99) while the backdrop still positions relative
to the outer wrapper.

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
The XDSTopNavMegaMenu backdrop (z-index 99) visually covered nav bar
items since they had no stacking context. Added position: relative and
zIndex: 100 to XDSTopNav base style so nav content renders above the
backdrop while the mega menu panel still paints on top.

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…ment (#378)

PR #377 incorrectly added position:relative + z-index to the <nav>
element, which made it the positioned ancestor for the MegaMenu
backdrop — breaking the unified card visual. The correct fix is to
add the stacking context to the nav's content sections (leftSection,
centerContent, rightSection, endContent) so they sit above the
backdrop (z-index 99) while the backdrop still positions relative
to the outer wrapper.

Co-authored-by: Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
The XDSTopNavMegaMenu backdrop (z-index 99) visually covered nav bar
items since they had no stacking context. Added position: relative and
zIndex: 100 to XDSTopNav base style so nav content renders above the
backdrop while the mega menu panel still paints on top.
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…ment (#378)

PR #377 incorrectly added position:relative + z-index to the <nav>
element, which made it the positioned ancestor for the MegaMenu
backdrop — breaking the unified card visual. The correct fix is to
add the stacking context to the nav's content sections (leftSection,
centerContent, rightSection, endContent) so they sit above the
backdrop (z-index 99) while the backdrop still positions relative
to the outer wrapper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant