Skip to content

feat(lab): explore shared-dialog BottomSheetSwitcher API - #5023

Merged
imdreamrunner merged 22 commits into
mainfrom
codex/bottom-sheet-orchestrator
Aug 15, 2026
Merged

imdreamrunner merged 22 commits into
mainfrom
codex/bottom-sheet-orchestrator

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR explores BottomSheetSwitcher, a controlled API for moving between a mutually exclusive set of BottomSheet children. One activeSheet ID selects the interactive sheet, while the switcher coordinates the shared modal boundary, scrim, focus behavior, and visual handoff.

The public state model stays intentionally small: one activeSheet value and one stable sheetId per child. This is a switcher rather than a navigation stack—it owns no history, depth, push, or pop behavior.

Interactive previews

Proposed API

<BottomSheetSwitcher
  activeSheet={activeSheet}
  onActiveSheetChange={setActiveSheet}>
  <BottomSheet sheetId="overview" label="Set up notifications">
    ...
  </BottomSheet>
  <BottomSheet sheetId="frequency" label="Notification frequency">
    ...
  </BottomSheet>
  <BottomSheet sheetId="channels" label="Notification channels">
    ...
  </BottomSheet>
</BottomSheetSwitcher>

BottomSheetSwitcher exposes the standard dialog DOM surface through BaseProps<HTMLDialogElement> and forwards its ref to the shared native <dialog>. Each BottomSheet consistently exposes its visual panel <div> through its DOM props and ref.

Behavior and architecture

  • The switcher renders inline in the React tree and does not use a portal.
  • It owns one native <dialog> for the complete flow; child sheets render as panel layers inside it.
  • With hasScrim={true}, the switcher uses showModal() to provide one top-layer boundary and one native ::backdrop across every handoff.
  • With hasScrim={false}, it uses show(), leaving the page interactive and scrollable. Consumers must avoid transformed, contained, or overflow-clipping ancestors in this mode.
  • During a handoff, only the incoming sheet is interactive. The outgoing sheet becomes inert and accessibility-hidden immediately.
  • The incoming sheet animates in above the outgoing sheet. If it is shorter, the taller outgoing sheet moves down concurrently, then fades after both transforms complete.
  • The shared dialog stays open through the final exit animation and restores focus to the original trigger afterward.
  • Escape handling respects IME composition and nested focus traps so only the top-most interaction layer closes.
  • Internal panel registration remains stable when a consumer callback ref changes during a transition.

Notification Setup example

The three-step example keeps state local to the sheet that owns it:

  1. Overview — read-only introduction with no required input.
  2. Frequency — a shorter sheet with a vertical single-select radio list.
  3. Channels — a taller sheet with independently toggleable channel preferences.

Moving Back preserves the mounted frequency and channel selections.

Feedback wanted

  • Is BottomSheetSwitcher the right name for a controlled single-selection API?
  • Is activeSheet plus child sheetId the right public state model?
  • Does one shared native dialog provide the expected semantics for both scrim modes?
  • Does the handoff feel coherent in both height directions?
  • Should transition lifecycle remain internal?

Validation

  • 63 focused tests pass across BottomSheet, BottomSheetPanel, BottomSheetSwitcher, and useFocusTrap
  • Core and Lab lint pass
  • Core and Lab builds pass
  • Lab documentation type-check passes
  • pnpm check:repo
  • pnpm sync:exports:check
  • Local mobile Storybook validation for Hug content and No scrim
  • Verified exactly one open dialog across handoffs
  • Verified modal mode remains viewport-sized under a transformed and clipped ancestor
  • Verified no-scrim mode keeps the background interactive and body scrolling enabled

This exploration builds on the standalone BottomSheet exit lifecycle from #5020 and targets main directly.

@vercel

vercel Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 15, 2026 6:49am

Request Review

@github-actions

github-actions Bot commented Aug 14, 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

BottomSheet (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 2407 -
Complexity N/A Very High (221) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB
@astryxdesign/lab N/A 3.7KB 1.6KB

Accessibility Audit

Status: No accessibility violations detected.


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

@imdreamrunner imdreamrunner changed the title feat(lab): explore multi-step BottomSheet orchestrator API feat(lab): preview multi-step BottomSheet orchestration Aug 14, 2026
github-actions Bot added a commit that referenced this pull request Aug 14, 2026
Base automatically changed from codex/bottom-sheet-standalone-exit to main August 14, 2026 17:27
@imdreamrunner
imdreamrunner force-pushed the codex/bottom-sheet-orchestrator branch from b835c16 to a1e79b1 Compare August 14, 2026 17:27
github-actions Bot added a commit that referenced this pull request Aug 14, 2026
github-actions Bot added a commit that referenced this pull request Aug 14, 2026
@imdreamrunner imdreamrunner changed the title feat(lab): preview multi-step BottomSheet orchestration feat(lab): explore BottomSheetSwitcher API Aug 15, 2026
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
@imdreamrunner imdreamrunner changed the title feat(lab): explore BottomSheetSwitcher API feat(lab): explore shared-dialog BottomSheetSwitcher API Aug 15, 2026
@imdreamrunner
imdreamrunner marked this pull request as draft August 15, 2026 01:11
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
@imdreamrunner
imdreamrunner force-pushed the codex/bottom-sheet-orchestrator branch from ea2c3a0 to 06511e9 Compare August 15, 2026 05:36
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
…chestrator

# Conflicts:
#	packages/lab/src/BottomSheet/BottomSheet.doc.mjs
#	packages/lab/src/BottomSheet/BottomSheet.test.tsx
#	packages/lab/src/BottomSheet/BottomSheet.tsx
@imdreamrunner
imdreamrunner enabled auto-merge (squash) August 15, 2026 06:57
@imdreamrunner
imdreamrunner merged commit fb0b7a9 into main Aug 15, 2026
19 checks passed
github-actions Bot added a commit that referenced this pull request Aug 15, 2026
@github-actions
github-actions Bot deleted the codex/bottom-sheet-orchestrator branch August 16, 2026 06:10

This branch was successfully deployed

1 active deployment
Preview — 17b742ea Deployed Aug 15, 2026 by vercel[bot]
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.

2 participants