Skip to content

feat(topnav): unified card appearance for mega menu without backdrop overlay - #379

Merged
rubyycheung merged 1 commit into
mainfrom
navi/feat/megamenu-unified-card
Feb 27, 2026
Merged

rubyycheung merged 1 commit into
mainfrom
navi/feat/megamenu-unified-card

Conversation

@rubyycheung

Copy link
Copy Markdown
Contributor

Summary

Removes the backdrop div from XDSTopNavMegaMenu and replaces it with a coordinated styling approach that creates the same unified card appearance without covering nav items.

Problem

The backdrop div (introduced for the unified card look) covered the entire positioned ancestor at z-index: 99, which required all nav sections to have z-index: 100 stacking contexts to remain interactive. This was fragile and created layering complexity.

Solution

Instead of an overlay, the unified card look is achieved by coordinating styles between the wrapper container and the dropdown panel:

  1. Wrapper (user code, via onOpenChange): adjusts border-radius and box-shadow when the menu opens — drops bottom radius so the nav bar flows seamlessly into the panel
  2. Panel: has a subtle top border (divider), no top radius, bottom rounded corners, and its own shadow — visually connects to the wrapper above
  3. TopNav sections: removed position: relative + z-index: 100 stacking context hacks (no longer needed)

Changes

File What changed
XDSTopNavMegaMenu.tsx Removed backdrop div and its styles. Panel now has top border, no top radius, explicit shadow. Removed elevationVars import.
XDSTopNav.tsx Removed position: relative and z-index: 100 from section wrappers — no longer needed without backdrop.
XDSTopNav.test.tsx Updated stacking context test to match simplified behavior.
mega-menu/page.tsx Enhanced wrapper styles: transitions border-radius when menu opens, uses directional shadow to maintain top/side card chrome while panel provides bottom shadow.

Test Plan

  • ✅ Build passes
  • ✅ All 1056 tests pass
  • ✅ Lint passes (0 errors)
  • Nav items remain fully visible and interactive (no overlay)
  • Unified card appearance maintained through coordinated wrapper + panel styles

…overlay

Removes the backdrop div from XDSTopNavMegaMenu that covered the entire
positioned ancestor. Instead, the unified card look is achieved by
coordinating styles between the wrapper and the panel:

- Wrapper (user code) adjusts border-radius when menu opens via onOpenChange
- Panel flows seamlessly below with matching background, bottom corners,
  a subtle top divider, and its own shadow
- Nav items remain fully visible and interactive — no overlay covering them
- Removed z-index stacking context hacks from TopNav sections (no longer
  needed without the backdrop)

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 899 -
Complexity N/A Very High (48) -

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 110a7fd Feb 27, 2026
10 checks passed
@thedjpetersen
thedjpetersen deleted the navi/feat/megamenu-unified-card branch March 1, 2026 11:02
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
…overlay (#379)

Removes the backdrop div from XDSTopNavMegaMenu that covered the entire
positioned ancestor. Instead, the unified card look is achieved by
coordinating styles between the wrapper and the panel:

- Wrapper (user code) adjusts border-radius when menu opens via onOpenChange
- Panel flows seamlessly below with matching background, bottom corners,
  a subtle top divider, and its own shadow
- Nav items remain fully visible and interactive — no overlay covering them
- Removed z-index stacking context hacks from TopNav sections (no longer
  needed without the backdrop)

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

Removes the backdrop div from XDSTopNavMegaMenu that covered the entire
positioned ancestor. Instead, the unified card look is achieved by
coordinating styles between the wrapper and the panel:

- Wrapper (user code) adjusts border-radius when menu opens via onOpenChange
- Panel flows seamlessly below with matching background, bottom corners,
  a subtle top divider, and its own shadow
- Nav items remain fully visible and interactive — no overlay covering them
- Removed z-index stacking context hacks from TopNav sections (no longer
  needed without the backdrop)

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

Removes the backdrop div from XDSTopNavMegaMenu that covered the entire
positioned ancestor. Instead, the unified card look is achieved by
coordinating styles between the wrapper and the panel:

- Wrapper (user code) adjusts border-radius when menu opens via onOpenChange
- Panel flows seamlessly below with matching background, bottom corners,
  a subtle top divider, and its own shadow
- Nav items remain fully visible and interactive — no overlay covering them
- Removed z-index stacking context hacks from TopNav sections (no longer
  needed without the backdrop)
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