Skip to content

fix(SideNav): make heading icon interactive when collapsed - #696

Merged
cixzhang merged 5 commits into
mainfrom
navi/fix/sidenav-heading-collapsed-icon
Mar 31, 2026
Merged

cixzhang merged 5 commits into
mainfrom
navi/fix/sidenav-heading-collapsed-icon

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When the SideNav is collapsed to its 52px icon-only toolbar, XDSSideNavHeading previously rendered the icon inside a plain <div> + <span> — making it completely non-interactive. Users couldn't click the heading icon to navigate or open menus.

This PR makes the collapsed heading icon properly interactive:

Behavior by prop combination

Props Collapsed rendering Interaction
headingHref <a> link Navigates to href
menu (no href) <button> Opens popover menu
headingHref + menu <a> link Navigates (href takes priority in icon-only mode)
Neither <div> (static) None (unchanged)

All collapsed variants include:

  • aria-label from the heading text for screen reader accessibility
  • XDSTooltip showing the heading name on hover (matches XDSSideNavItem pattern)
  • navItemStyles.item for consistent appearance with other nav items
  • Popover placement: 'end' for collapsed menu (opens to the side rather than below)

Tests

Added 9 new tests covering all collapsed heading interaction modes.

Fixes #565


@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 18, 2026
@github-actions

github-actions Bot commented Mar 18, 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

SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.2KB N/A
Lines of Code N/A 1526 -
Complexity N/A Very High (150) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 11.7KB 18.6KB 2.9KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

XDSSideNav - 1 issue(s)
  • 🟠 serious: Ensure links have discernible text
    • Rule: link-name · Affects 1/8 stories · Learn more
    • WCAG: 2.4.4, 4.1.2 (Level A)

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

@cixzhang
cixzhang force-pushed the navi/fix/sidenav-heading-collapsed-icon branch 3 times, most recently from a328146 to 1f1eda1 Compare March 19, 2026 16:50
Navi and others added 4 commits March 24, 2026 22:26
When the SideNav is collapsed, XDSSideNavHeading now renders an interactive
element instead of a plain div:

- headingHref → renders as <a> link so clicking navigates
- menu (no href) → renders as <button> that triggers the popover
- headingHref + menu → prefers link (href takes priority in icon-only mode)
- Neither → renders as static div (no change from before)

All collapsed variants include:
- aria-label from the heading text for accessibility
- XDSTooltip showing the heading name on hover (matches XDSSideNavItem)
- navItemStyles.item for consistent appearance with other nav items
- Popover placement: 'end' for collapsed menu (opens to the side)

Fixes #565

Co-authored-by: Navi <[email protected]>
- Add popoverCollapsed style with marginInlineStart (not marginBlockStart)
  and minWidth: 180px for end placement
- Use popoverCollapsed xstyle for the collapsed menu popover render

Co-authored-by: Navi <[email protected]>
Collapsed heading now only supports link navigation (href) or
static icon. Menu popover in collapsed mode was not positioning
correctly — removed for now. Can revisit later.

Co-authored-by: Navi <[email protected]>
Added popoverCollapsed style for collapsed mode popover positioning.
The style was referenced but never defined, causing a TypeScript error.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang force-pushed the navi/fix/sidenav-heading-collapsed-icon branch from 1f1eda1 to 3711373 Compare March 24, 2026 22:27
The collapsed popover menu is not working yet. Simplify the collapsed
heading to two modes: link (headingHref) or static icon (div). Menu-only
headings fall back to static icon in collapsed state.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang marked this pull request as ready for review March 31, 2026 22:06
@cixzhang
cixzhang merged commit f49db08 into main Mar 31, 2026
14 checks passed
@cixzhang
cixzhang deleted the navi/fix/sidenav-heading-collapsed-icon branch April 9, 2026 14:33
cixzhang added a commit that referenced this pull request Apr 26, 2026
* fix(SideNav): make heading icon interactive when collapsed

When the SideNav is collapsed, XDSSideNavHeading now renders an interactive
element instead of a plain div:

- headingHref → renders as <a> link so clicking navigates
- menu (no href) → renders as <button> that triggers the popover
- headingHref + menu → prefers link (href takes priority in icon-only mode)
- Neither → renders as static div (no change from before)

All collapsed variants include:
- aria-label from the heading text for accessibility
- XDSTooltip showing the heading name on hover (matches XDSSideNavItem)
- navItemStyles.item for consistent appearance with other nav items
- Popover placement: 'end' for collapsed menu (opens to the side)

Fixes #565

Co-authored-by: Navi <[email protected]>

* fix: collapsed heading popover positioning and sizing

- Add popoverCollapsed style with marginInlineStart (not marginBlockStart)
  and minWidth: 180px for end placement
- Use popoverCollapsed xstyle for the collapsed menu popover render

Co-authored-by: Navi <[email protected]>

* fix: remove menu interaction in collapsed mode, keep link only

Collapsed heading now only supports link navigation (href) or
static icon. Menu popover in collapsed mode was not positioning
correctly — removed for now. Can revisit later.

Co-authored-by: Navi <[email protected]>

* fix: add missing popoverCollapsed style definition

Added popoverCollapsed style for collapsed mode popover positioning.
The style was referenced but never defined, causing a TypeScript error.

Co-authored-by: Navi <[email protected]>

* fix: remove popover menu in collapsed state

The collapsed popover menu is not working yet. Simplify the collapsed
heading to two modes: link (headingHref) or static icon (div). Menu-only
headings fall back to static icon in collapsed state.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* fix(SideNav): make heading icon interactive when collapsed

When the SideNav is collapsed, XDSSideNavHeading now renders an interactive
element instead of a plain div:

- headingHref → renders as <a> link so clicking navigates
- menu (no href) → renders as <button> that triggers the popover
- headingHref + menu → prefers link (href takes priority in icon-only mode)
- Neither → renders as static div (no change from before)

All collapsed variants include:
- aria-label from the heading text for accessibility
- XDSTooltip showing the heading name on hover (matches XDSSideNavItem)
- navItemStyles.item for consistent appearance with other nav items
- Popover placement: 'end' for collapsed menu (opens to the side)

Fixes #565

Co-authored-by: Navi <[email protected]>

* fix: collapsed heading popover positioning and sizing

- Add popoverCollapsed style with marginInlineStart (not marginBlockStart)
  and minWidth: 180px for end placement
- Use popoverCollapsed xstyle for the collapsed menu popover render

Co-authored-by: Navi <[email protected]>

* fix: remove menu interaction in collapsed mode, keep link only

Collapsed heading now only supports link navigation (href) or
static icon. Menu popover in collapsed mode was not positioning
correctly — removed for now. Can revisit later.

Co-authored-by: Navi <[email protected]>

* fix: add missing popoverCollapsed style definition

Added popoverCollapsed style for collapsed mode popover positioning.
The style was referenced but never defined, causing a TypeScript error.

Co-authored-by: Navi <[email protected]>

* fix: remove popover menu in collapsed state

The collapsed popover menu is not working yet. Simplify the collapsed
heading to two modes: link (headingHref) or static icon (div). Menu-only
headings fall back to static icon in collapsed state.

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* fix(SideNav): make heading icon interactive when collapsed

When the SideNav is collapsed, XDSSideNavHeading now renders an interactive
element instead of a plain div:

- headingHref → renders as <a> link so clicking navigates
- menu (no href) → renders as <button> that triggers the popover
- headingHref + menu → prefers link (href takes priority in icon-only mode)
- Neither → renders as static div (no change from before)

All collapsed variants include:
- aria-label from the heading text for accessibility
- XDSTooltip showing the heading name on hover (matches XDSSideNavItem)
- navItemStyles.item for consistent appearance with other nav items
- Popover placement: 'end' for collapsed menu (opens to the side)

Fixes #565


* fix: collapsed heading popover positioning and sizing

- Add popoverCollapsed style with marginInlineStart (not marginBlockStart)
  and minWidth: 180px for end placement
- Use popoverCollapsed xstyle for the collapsed menu popover render


* fix: remove menu interaction in collapsed mode, keep link only

Collapsed heading now only supports link navigation (href) or
static icon. Menu popover in collapsed mode was not positioning
correctly — removed for now. Can revisit later.


* fix: add missing popoverCollapsed style definition

Added popoverCollapsed style for collapsed mode popover positioning.
The style was referenced but never defined, causing a TypeScript error.


* fix: remove popover menu in collapsed state

The collapsed popover menu is not working yet. Simplify the collapsed
heading to two modes: link (headingHref) or static icon (div). Menu-only
headings fall back to static icon in collapsed state.


---------
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.

Deep review: Shell & Navigation surface

1 participant