Repository navigation
refactor(MegaMenu): composed children API + mobile drawer drill-down - #659
Merged
Merged
Conversation
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsTopNav · View in Storybook · 🆕 XDSTopNavMegaMenuItem, XDSTopNavMegaMenuFeaturedCard
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Refactors XDSTopNavMegaMenu from structured data props to a composed
children API and adds mobile drawer drill-down support.
## Composed Children API
Before:
```tsx
<XDSTopNavMegaMenu label="Products" items={[...]} featured={{...}} />
```
After:
```tsx
<XDSTopNavMegaMenu label="Products">
<XDSTopNavMegaMenuGroup>
<XDSTopNavMegaMenuItem title="Analytics" description="Track behavior" icon={<ChartIcon />} href="/analytics" />
</XDSTopNavMegaMenuGroup>
<XDSTopNavMegaMenuFeatured>
{/* any ReactNode */}
</XDSTopNavMegaMenuFeatured>
</XDSTopNavMegaMenu>
```
New sub-components:
- XDSTopNavMegaMenuGroup — wraps items (renders in XDSGrid)
- XDSTopNavMegaMenuItem — individual item (title, description?, icon?, href?)
- XDSTopNavMegaMenuFeatured — featured area accepting children
Removed props: items, featured, isSingleColumn
Kept props: label, delay, hideDelay, onOpenChange, children
## Mobile Drawer Mode
Uses useXDSTopNavRenderMode() from XDSTopNavRenderContext:
- 'default': existing popover mega menu (unchanged)
- 'mobile-bar': returns null (hidden in compact bar)
- 'drawer': drill-down navigation with back button + item list
Part of #565
Replace drill-down navigation with inline collapsible, consistent with how TopNavMenu renders in mobile drawers. Changes: - Drawer trigger: chevronDown/up (was chevronRight drill-down) - Drawer items: use navItemStyles.item base + indentation override - Items show title, description, and icon (was title + icon only) - Featured card now renders inside the expanded drawer section - aria-expanded + aria-controls wired up on the toggle button - Animated expand/collapse via grid-template-rows transition - Updated tests to reflect new collapsible behavior, added coverage for descriptions and featured card in drawer mode Co-authored-by: Navi <[email protected]>
cixzhang
force-pushed
the
navi/refactor/mega-menu-composed
branch
from
March 18, 2026 12:41
d43b1ee to
6c45a5d
Compare
…ng MenuItem Replace composed children API (XDSTopNavMegaMenuGroup, XDSTopNavMegaMenuFeatured) with direct ReactNode slots on XDSTopNavMegaMenu: - items: ReactNode slot for menu items (typically XDSTopNavMegaMenuItem) - featured: ReactNode slot for the featured card XDSTopNavMegaMenuItem is now a real rendering component that handles both desktop (popover grid item with icon/title/description) and drawer (navItemStyles base with indentation) modes via XDSTopNavRenderContext. Removed: - XDSTopNavMegaMenuGroup (was a semantic wrapper, no longer needed) - XDSTopNavMegaMenuFeatured (was a semantic wrapper, no longer needed) - parseChildren helper (no child introspection needed) The slots are open ReactNode — consumers can pass XDSTopNavMegaMenuItem for the standard appearance, or anything else for custom layouts. Co-authored-by: Navi <[email protected]>
New XDSTopNavMegaMenuFeaturedCard component provides a standard card with optional image, title, description, and CTA link for the featured slot. The slot remains open ReactNode for custom content. Updated: - TopNav.doc.mjs: all 3 locales updated to slots API (items/featured) - TopNav/index.ts: export FeaturedCard + props type - Shell lab, mega-menu sandbox, storybook: use FeaturedCard Co-authored-by: Navi <[email protected]>
Co-authored-by: Navi <[email protected]>
cixzhang
marked this pull request as ready for review
March 18, 2026 14:20
52 of 55 tasks
cixzhang
added a commit
that referenced
this pull request
Apr 26, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MegaMenu: Slots API + FeaturedCard + Consistent Mobile Drawer
Refactors XDSTopNavMegaMenu to use ReactNode slots, adds a standard featured card component, and aligns mobile drawer rendering with the rest of the shell.
API
items— ReactNode slot for menu items (typically XDSTopNavMegaMenuItem, accepts anything)featured— ReactNode slot for featured content (typically XDSTopNavMegaMenuFeaturedCard, accepts anything)Components
XDSTopNavMegaMenuItem — real rendering component (was declarative-only):
XDSTopNavMegaMenuFeaturedCard — new standard card:
Mobile Drawer
Inline collapsible matching TopNavMenu/SideNavItem patterns:
Removed
Docs
TopNav.doc.mjs updated across all 3 locales.