Skip to content

fix(topnav): move mega menu stacking context to nav sections - #378

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

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

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Problem

PR #377 added position: relative + zIndex: 100 to the <nav> element to fix the mega menu backdrop covering nav items. This was incorrect — it made the <nav> the positioned ancestor for the backdrop, changing the backdrop's coverage area and breaking the unified card visual.

Fix

Moved the stacking context from the <nav> element to its content sections (leftSection, centerContent, rightSection, endContent). This way:

  • The backdrop still positions relative to the outer wrapper (preserving the unified card effect)
  • Each content section creates its own stacking context above the backdrop (z-index 99)
  • Nav items remain visible and interactive when the mega menu is open

Test Plan

  • Updated unit test to verify content sections have position: relative (not the nav element)
  • All 1056 tests pass
  • Build and lint clean

…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]>
@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 930 -
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 dca18d9 Feb 27, 2026
10 checks passed
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
…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
…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