Repository navigation
Closed
Labels
enhancementNew feature or request
Milestone
Description
Problem
XDSTopNavMegaMenu and XDSTopNavMenu have API issues:
- Data props instead of composition —
items: Array<{title, description, icon, href}>andfeatured: {image, title, ...}bake layout into the component. Consumers can't compose arbitrary content. - Hover-only interaction — No click path, broken on touch, limited keyboard support.
XDSTopNavMenuusesuseXDSHoverCardwhich puts content in tab order but has no focus trap or arrow key navigation. - Wrapper div boilerplate —
XDSTopNavMegaMenurequires consumers to wrapXDSTopNavin aposition: relativediv for full-width positioning. - Duplicated trigger styling — Both components render their own trigger button that duplicates
XDSTopNavItemstyling. - No controlled state — Neither supports
isShown/onTogglefor controlled open/close. Vibe test showed both agents abandoned these components entirely for controlled scenarios (mm-7). - z-index stacking —
XDSTopNavMegaMenuused manualz-index: 100instead of the top layer, causing the cascade of fixes in fix(topnav): mega menu backdrop no longer covers nav items #377/fix(topnav): move mega menu stacking context to nav sections #378/feat(topnav): unified card appearance for mega menu without backdrop overlay #379. XDSDropdownMenuItemnaming — The menu item component is scoped to "Dropdown" but works in nav menus too.
Proposal: Rework both components + introduce XDSMenuItem
Keep both components but make them compositional. Each encodes the correct ARIA pattern while delegating layout to the consumer.
XDSTopNavMenu — role="menu" pattern
A nav item that opens a dropdown menu. Click-triggered. Uses XDSPopover internally for top layer, focus trap, light dismiss, and keyboard support.
<XDSTopNav
startContent={
<>
<XDSTopNavItem label="Home" href="/" isSelected />
<XDSTopNavMenu label="Products">
<XDSMenuItem label="Analytics" description="Track behavior" icon="chart" href="/analytics" />
<XDSMenuItem label="Platform" description="Build at scale" icon="layers" href="/platform" />
<XDSMenuItem label="Security" description="Enterprise protection" icon="shield" href="/security" />
</XDSTopNavMenu>
<XDSTopNavItem label="Pricing" href="/pricing" />
</>
}
/>Changes from current:
childrenslot replacesitemsdata prop — acceptsXDSMenuItemchildren- Click-triggered (via
XDSPopover) instead of hover-only role="menu"on container,role="menuitem"on eachXDSMenuItem- Focus trap, Escape to close, light dismiss — all from
XDSPopover - Trigger styled as
XDSTopNavItem(no duplicated styling) labelprop stays (static trigger text — does NOT update with selection, confirmed current behavior)
XDSTopNavMegaMenu — button + role="dialog" pattern
A nav item that opens a full-width panel for rich content. Uses role="dialog" because mega menu content is mixed (links, images, headings) — not a flat menu.
<XDSTopNav
startContent={
<XDSTopNavMegaMenu label="Solutions">
<XDSHStack gap="space6">
<XDSGrid columns={2} gap="space2">
<XDSMenuItem label="Enterprise" description="Scale solutions" href="/enterprise" />
<XDSMenuItem label="Startups" description="Get started fast" href="/startups" />
<XDSMenuItem label="Developers" description="APIs and tools" href="/developers" />
<XDSMenuItem label="Partners" description="Join the ecosystem" href="/partners" />
</XDSGrid>
<XDSVStack gap="space3">
<XDSHeading level={3}>What's new</XDSHeading>
<XDSText>Explore the latest platform updates.</XDSText>
<XDSLink href="/blog">Learn more</XDSLink>
</XDSVStack>
</XDSHStack>
</XDSTopNavMegaMenu>
}
/>Changes from current:
childrenslot replacesitems+featureddata props — compose any layout- Auto-anchors to nearest
XDSTopNavancestor — no wrapper div needed, noanchorRefboilerplate - Click-triggered instead of hover-only
role="dialog"(rich content, not a flat menu)- Full-width by default (anchored to nav), with optional
widthprop
XDSMenuItem — shared menu item component
Rename XDSDropdownMenuItem → XDSMenuItem. Works inside any menu container.
import {XDSMenuItem} from '@xds/core/Menu';
// In a dropdown menu
<XDSDropdownMenu button={<XDSButton label="Actions" />}>
<XDSMenuItem label="Edit" icon="edit" />
<XDSMenuItem label="Delete" icon="trash" variant="destructive" />
</XDSDropdownMenu>
// In a nav menu
<XDSTopNavMenu label="Products">
<XDSMenuItem label="Analytics" description="Track behavior" icon="chart" href="/analytics" />
</XDSTopNavMenu>
// In a mega menu
<XDSTopNavMegaMenu label="Solutions">
<XDSMenuItem label="Enterprise" description="Scale solutions" href="/enterprise" />
</XDSTopNavMegaMenu>- Same props:
label,description,icon,href,onClick,variant - Container handles ARIA roles (
role="menuitem"applied by the menu container) XDSDropdownMenuItemkept as deprecated re-export for backward compat- Moves to
@xds/core/Menu
Migration
| Before | After |
|---|---|
XDSTopNavMenu label="X" items={[...]} |
XDSTopNavMenu label="X"> <XDSMenuItem .../> </XDSTopNavMenu> |
XDSTopNavMegaMenu label="X" items={[...]} featured={{...}} |
XDSTopNavMegaMenu label="X"> <composed content> </XDSTopNavMegaMenu> |
div style={{position:"relative"}} wrapper |
Gone — auto-anchoring |
XDSDropdownMenuItem |
XDSMenuItem (deprecated re-export available) |
| Hover-only interaction | Click-triggered with focus trap |
Vibe test evidence
Mega menu API test (8 prompts × 2 configs)
- Composed pattern was correct on all 8 prompts (real a11y, natural layouts)
- Monolithic was more concise on 2/8 prompts but shoehorned layouts and hallucinated a11y
- Both agents abandoned nav menu components for controlled state (mm-7) — confirms data props aren't needed for trigger updates
- XDSTopNavMegaMenu only used 2/8 times even when available
XDSMenuItem rename test (5 prompts × 2 configs)
- Zero confusion — XDSMenuItem used correctly in XDSDropdownMenu, XDSTopNavMenu, and both on the same page
- Generic name reads naturally in every context
- Current name (
XDSDropdownMenuItem) already crosses context boundaries without issues
Full results: memory/vibe-test-mega-menu-results.md
Related
- Eliminate z-index stacking — use top layer (Popover API) for all overlays #411 — z-index elimination (this subsumes the mega menu portion)
- fix(topnav): use Popover API + CSS anchor positioning for mega menu #412 — Initial top layer fix (will be superseded by this)
- feat(topnav): add XDSTopNavMegaMenu component #354, feat(topnav): unified card appearance for mega menu #356, fix(topnav): mega menu backdrop no longer covers nav items #377, fix(topnav): move mega menu stacking context to nav sections #378, feat(topnav): unified card appearance for mega menu without backdrop overlay #379 — The cascade of mega menu fixes that led here
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
cixzhang commentedon Mar 3, 2026
Correction: Layout components in examples
The issue examples reference
XDSColumnswhich doesn't exist. The actual layout primitives are:XDSHStack/XDSVStack— flex-based stacksXDSGrid+XDSGridSpan— CSS grid withcolumns,minChildWidth,gapUpdated mega menu example using real components:
cixzhang commentedon Mar 3, 2026
Refined spec (from vibe test findings + Cindy feedback)
Keep both components, but make them compositional
The vibe test showed monolithic components are only useful for 2/8 nav scenarios, but Cindy points out they still earn their existence by encoding the right ARIA pattern — that's semantic, not just convenience.
XDSTopNavMenu—role="menu"/role="menuitem"patternXDSTopNavItem-styled button witharia-haspopup="menu"childrenslot (notitemsdata prop) — consumer composes menu itemsXDSPopoverinternally for layering (top layer, focus trap, light dismiss)role="menu"on the container and expectsrole="menuitem"on childrenlabelprop for the trigger text (static — does NOT update with selection, confirmed both current components use static labels)XDSTopNavMegaMenu— button +role="dialog"patternXDSTopNavItem-styled buttonchildrenslot (notitems/featureddata props)XDSPopoverinternally with auto-anchoring to nearestXDSTopNavancestor — no wrapper div needed, noanchorRefboilerplaterole="dialog"since mega menu content is rich/mixed (not a flat menu)widthprop for custom sizingAuto-anchoring eliminates wrapper div boilerplate
Current composed pattern requires:
With auto-anchoring,
XDSTopNavMegaMenuwalks up to find itsXDSTopNavancestor (which already usesforwardRef) and anchors to it automatically:No ref, no wrapper div, no
width="anchor".What changes from original #414
itemsdata propchildrenslot (composition)featureddata propwidth="anchor"on XDSPopoverVibe test evidence
itemsdata prop isn't needed for trigger label updatesmemory/vibe-test-mega-menu-results.mdcixzhang commentedon Mar 3, 2026
XDSMenuItem — shared menu item component
Vibe tested renaming
XDSDropdownMenuItem→XDSMenuItemacross 5 prompts × 2 configs. Zero confusion. The generic name works naturally in every context.What changes
XDSDropdownMenuItem→XDSMenuItem— moves from@xds/core/DropdownMenuto@xds/core/MenuXDSMenuItemworks inside bothXDSDropdownMenuandXDSTopNavMenuXDSDropdownMenuItemas a deprecated re-export for backward compatAPI
Same component, same props, different containers. The container handles the ARIA pattern (
role="menu"on the list,role="menuitem"on each item).Vibe test evidence
Full results:
memory/vibe-test-mega-menu-results.md