Skip to content

feat: shell hardening batch — entry animation, TopNavMenu mobile, collapsible items (#565) - #657

Merged
cixzhang merged 16 commits into
mainfrom
navi/feat/shell-hardening-batch
Mar 18, 2026
Merged

cixzhang merged 16 commits into
mainfrom
navi/feat/shell-hardening-batch

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Shell Hardening Batch — #565

Addresses remaining items from the shell & navigation deep review, plus mobile interaction hardening discovered during review.

Features

Collapsible SideNavItem — items with children are now collapsible by default:

  • No collapsible prop needed — items with children automatically get expand/collapse
  • Pass collapsible={false} to opt out
  • Animated expand/collapse via grid-template-rows transition
  • Chevron icon rotates to indicate state
  • aria-expanded + aria-controls linking toggle to children group

TopNavMenu mobile drawer mode — menus render as collapsible sections in the mobile drawer:

  • Expandable header with chevron animation
  • Child items indented with shared nav item styles
  • aria-expanded + aria-controls for accessibility

MobileNav breakpoint config — moved sideNavBreakpoint and sideNavWidth from AppShell props into the mobileNav config object:

  • mobileNav={{ breakpoint: 'lg' }} instead of sideNavBreakpoint="lg"
  • Removed dead sideNavWidth prop (SideNav owns its own width)

Shared navItemStyles — extracted common nav item styles into NavItem/navItemStyles.stylex.ts:

  • navItemStyles.item / .selected / .disabled — single source of truth
  • Consumed by SideNavItem, TopNavItem (drawer), TopNavMenu (drawer)
  • Exported publicly via @xds/core/NavItem for custom nav items

Mobile Interaction Hardening

Pressed states — added :active to all interactive nav items via shared navItemStyles

Tooltip touch suppression:

  • mouseenter: guarded with (hover: none) media query
  • focusin: only shows when :focus-visible matches (keyboard only)

MobileNav scroll lock + overlay:

  • overflow: clip on <html> when open — no scroll bounce, no save/restore needed
  • touch-action: none on dialog, pan-y on content area
  • overscrollBehavior: contain on dialog root
  • backdropFilter: blur(2px) matching Dialog overlay style

Focus ring suppression on touch:

  • reset.css: @media (hover: none) and (pointer: coarse) suppresses :focus-visible outlines
  • MobileNav drawer panel gets tabIndex={-1} so showModal() focuses the drawer (outline: none), not the close button
  • Removed redundant tooltip from close button

Drawer Spacing & Content

  • Drawer content padding: 8px all around (was 4px block)
  • SideNav footer + footerIcons now render in both drawer modes (was missing footerIcons)
  • Drawer footer pushed to bottom with marginBlockStart: auto + divider
  • 8px block margin around divider between TopNav and SideNav items in combined drawer

Style Consistency

TopNav items in mobile drawer now match SideNavItem via shared navItemStyles:

  • spacing-2 gap/padding, font-weight-normal, color-text-primary
  • XDSDivider with 8px margin between TopNav and SideNav sections

Removed (separate PR)

  • @starting-style entry animations — needs manual debugging

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

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

New Components

NavItem
Metric Value
Bundle Size (ESM) 181B
Bundle Size (CJS) 288B
Lines of Code 58
Source Files 2
Complexity Low (1)
Exports navItemStyles
Props Count N/A
Has Tests No
Has Stories No

Modified Components

AppShell · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 801B N/A
Lines of Code N/A 544 -
Complexity N/A Very High (88) -
MobileNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 615B N/A
Lines of Code N/A 315 -
Complexity N/A Very High (32) -
SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.1KB N/A
Lines of Code N/A 1170 -
Complexity N/A Very High (127) -
Tooltip · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 241B N/A
Lines of Code N/A 403 -
Complexity N/A Very High (47) -
TopNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.0KB N/A
Lines of Code N/A 1290 -
Complexity N/A Very High (84) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 10.4KB 16.5KB 2.6KB

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 changed the title feat: shell hardening batch — entry animation + TopNavMenu mobile (#565) feat: shell hardening batch — entry animation, TopNavMenu mobile, collapsible items (#565) Mar 17, 2026
@cixzhang
cixzhang force-pushed the navi/feat/shell-hardening-batch branch from 252376b to 594ac19 Compare March 17, 2026 19:36
navi[bot] added 3 commits March 18, 2026 04:47
MobileNav entry animation:
- @starting-style on backdrop (opacity 0→1)
- @starting-style on drawer transforms (slide in from off-screen)
- Close animation unchanged (delayed dialog.close)

TopNavMenu drawer mode:
- Returns null in mobile-bar mode (hidden from simplified top bar)
- Renders as collapsible section in drawer mode:
  - Tappable header with chevron that rotates on expand
  - Items shown as vertical list with icon + title + description
  - Smooth expand/collapse via grid-template-rows transition
- Default desktop popover unchanged

Co-authored-by: Navi <[email protected]>
Items with children are now collapsible:
- Click toggles expand/collapse (items with children become toggle-only)
- Chevron icon rotates to indicate state (via getIcon('chevronDown'))
- Smooth animation via grid-template-rows transition
- defaultIsExpanded (default: true) for uncontrolled mode
- isExpanded + onExpandedChange for controlled mode
- Skipped when sidebar is collapsed (children already hidden)

Co-authored-by: Navi <[email protected]>
Items with children can now be made collapsible via the collapsible prop,
matching the same pattern used on XDSSideNav:

  <XDSSideNavItem label="Nav" icon={icon} collapsible>
    <XDSSideNavItem label="Sub 1" />
  </XDSSideNavItem>

  // Or controlled:
  <XDSSideNavItem collapsible={{ isCollapsed, onCollapsedChange }}>

- collapsible?: boolean | { defaultIsCollapsed?, isCollapsed?, onCollapsedChange? }
- Click toggles collapse (items with children become toggle-only)
- Chevron icon rotates to indicate state
- Smooth animation via grid-template-rows transition
- Skipped when sidebar is collapsed (children already hidden)

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

Copy link
Copy Markdown
Contributor Author
  • animation is still incorrect so remove it for now and move that to a separate PR. Will debug that manually.
  • collapsible looks good!
  • when in the mobile nav, let's make the top nav items reuse the same appearance as the side nav items. They could render them directly when in the mobile nav
  • let's get some more separation between top nav items and side nav items in the mobile nav and out a divider equally spaced between the top nav pans and the side nav content in the mobile nav that combines them.

@cixzhang
cixzhang force-pushed the navi/feat/shell-hardening-batch branch from 594ac19 to c339772 Compare March 18, 2026 05:05
cixzhang and others added 7 commits March 18, 2026 05:23
… divider

- Remove @starting-style entry animations from MobileNav (move to separate PR)
- TopNavItem drawer mode now matches XDSSideNavItem styles exactly
  (spacing-2 gap/padding, font-weight-normal, color-text-primary)
- TopNavMenu drawer header/items also updated to match SideNavItem
- Add XDSDivider between TopNav items and SideNav items in combined drawer

Co-authored-by: Navi <[email protected]>
…on, scroll lock, backdrop blur

- Add :active (pressed) states to SideNavItem, TopNavItem drawer mode,
  and TopNavMenu drawer header/items — essential for mobile tap feedback
- Tooltip: suppress on touch devices (hover: none) to prevent eating taps
- Tooltip: only show on focusin when :focus-visible matches (keyboard only),
  prevents tooltip flash on dialog auto-focus
- MobileNav: add backdropFilter: blur(2px) to match Dialog overlay style
- MobileNav: lock body scroll on open (position: fixed technique) to prevent
  iOS pull-to-refresh and background content scrolling
- MobileNav: touch-action: none on dialog root, pan-y on content area
- MobileNav: overscrollBehavior: contain on dialog root
- MobileNav: restore scroll position on close/unmount

Co-authored-by: Navi <[email protected]>
- SideNavItem: toggle button gets aria-expanded and aria-controls
  pointing to the children group container
- TopNavMenu drawer: toggle button gets aria-controls pointing to
  the expandable items container
- Screen readers now properly announce expand/collapse state and
  the relationship between toggle and controlled content

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

Replace the classic body position: fixed + scroll save/restore hack with
a single overflow: clip on <html>. clip doesn't create a scroll container
so there's no bounce, no scrollbar shift, and no need to save/restore
scroll position.

Co-authored-by: Navi <[email protected]>
Create NavItem/navItemStyles.stylex.ts with the shared base item, selected,
and disabled styles used across all nav item components. Eliminates the
triple-duplication that required updating 3 files for every style change.

- navItemStyles.item — base layout, typography, hover/active states
- navItemStyles.selected — deemphasized background, medium weight
- navItemStyles.disabled — muted color, no interaction

Updated consumers:
- SideNavItem: uses navItemStyles.item/selected/disabled, keeps local
  collapsed/children/label styles
- TopNavItem: uses navItemStyles for drawer mode + disabled, keeps local
  desktop base/selected and focus outline styles
- TopNavMenu: composes navItemStyles.item with local header (space-between)
  and item (indentation) overrides

Exported publicly via @xds/core/NavItem for consumers building custom
nav items that need to match the system appearance.

Co-authored-by: Navi <[email protected]>
:focus-visible is supported in all browsers since 2022.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang marked this pull request as ready for review March 18, 2026 11:03
cixzhang and others added 6 commits March 18, 2026 11:23
…ix drawer focus

- SideNavItem: items with children are now collapsible by default.
  Pass collapsible={false} to opt out. Previously required explicit
  collapsible={true}.

- reset.css: suppress :focus-visible outlines on touch-only devices
  via @media (hover: none) and (pointer: coarse). Focus rings serve
  keyboard users — on touch devices they're noise that flashes on
  tap, dialog auto-focus, and programmatic focus.

- MobileNav: remove tooltip from close button (redundant with
  aria-label, caused tooltip flash on dialog open). Add tabIndex={-1}
  on drawer panel so showModal() focuses the drawer container (which
  has outline: none) instead of the close button.

Co-authored-by: Navi <[email protected]>
- MobileNav: content padding is now 8px all around (was 4px block)
- SideNav drawer/drawer-content: render footerIcons (was missing)
- SideNav drawer footer: pushed to bottom with marginBlockStart: auto,
  separated by a divider line
- TopNav drawer: 8px block margin around the divider between TopNav
  items and SideNav items, removed extra margin on SideNav content

Co-authored-by: Navi <[email protected]>
Collapsed chevron now rotates 180° (up) instead of -90° (right),
matching the TopNavMenu drawer toggle behavior.

Co-authored-by: Navi <[email protected]>
…v is in drawer

When both topNav and sideNav are provided with the elevated variant,
the content area was getting a transparent background on all screen
sizes. On mobile the sidenav is in the drawer (not inline), so the
wash background showed through making it appear fully gray.

Now checks isBelowBreakpoint — on mobile, elevated behaves like
top-nav-only and uses the surface content background.

Co-authored-by: Navi <[email protected]>
- Auto mobile top bar (sidenav-only layouts) now gets sticky positioning
  and opaque background in auto height mode, matching TopNav behavior
- Elevated variant: use surface bg on mobile when sidenav is in drawer
  (was showing transparent/gray wash background)

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

SideNav topbar mode had its own paddingInline: 8px on top of the
auto mobile top bar's 8px, making the heading 24px from edge vs
TopNav mobile bar's 16px. Remove the topbar padding so the chain
is: auto mobile top bar (8px) + heading (8px) = 16px.

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang merged commit eea61e3 into main Mar 18, 2026
11 checks passed
@cixzhang
cixzhang deleted the navi/feat/shell-hardening-batch branch March 18, 2026 12:25
cixzhang added a commit that referenced this pull request Apr 26, 2026
cixzhang added a commit that referenced this pull request Jun 21, 2026
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