Skip to content

feat(lab): align Drawer dismissal and close control with Dialog - #6877

Merged
imdreamrunner merged 3 commits into
mainfrom
feat/lab-drawer-align-dialog
Oct 2, 2026
Merged

imdreamrunner merged 3 commits into
mainfrom
feat/lab-drawer-align-dialog

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

User need

Builders who know Dialog expect Drawer to dismiss and close the same way, and today it does not:

  • Drawer always closes on Escape and on a scrim click. A drawer holding a form loses unsaved input to a stray scrim click, and a mandatory flow cannot block dismissal. Dialog and BottomSheet solve both with purpose.
  • Drawer paints a floating close button in the top-trailing corner unless hasCloseButton={false}, and its docs tell builders to leave clearance for it in their own header row. Dialog has no built-in button: DialogHeader renders one in the title row only when given onOpenChange.

Aligning the two before Drawer is promoted out of Lab means a Dialog user already knows the Drawer API.

Problem and solution fit

  • purpose on Drawer, with Dialog's values and default. It is the missing dismissal control. BottomSheet already reuses the same type.
  • Built-in close button and hasCloseButton removed. This is the difference from Dialog.
  • DrawerHeader, with DialogHeader's API. Without the built-in button, a drawer needs a Dialog-style place for its close action, especially a non-modal drawer, which has no scrim to click.
  • Docs, examples, the six runnable docsite blocks, and Storybook now compose DrawerHeader, so the documented recipe matches the new API.

Current specification

component:Drawer (packages/lab/src/Drawer/Drawer.spec.md, draft) is updated in this PR with the owner decision as DEC-1, plus FR7, the new FR15, AR2/AR3/AR5, AV4/AV6, and the public-concepts table. The record stays draft, so spec-owner-approval does not need an owner comment. purpose uses the existing close/block Escape behavior of family:overlay-dismissal; no family change is needed.

Public delta and caller burden

Before After
Close button Built in, top-trailing; hasCloseButton (default true) None built in. DrawerHeader renders one when given onOpenChange
hasCloseButton Supported Removed
purpose Not supported (always closes on Escape and scrim click) 'required' | 'form' | 'info', default 'info', same as Dialog
Exports Drawer, DrawerProps adds DrawerHeader, DrawerHeaderProps
Theming astryx-drawer adds astryx-drawer-header, -start-content, -title-block, -end-content, -close-icon

purpose behavior:

  • info (default): Escape, platform close, and a scrim click close the drawer. This is today's behavior.
  • form: Escape closes; a scrim click does not.
  • required: nothing closes it. Escape is consumed (block), so it cannot reach a layer behind, and a modal drawer gets role="alertdialog".
  • A non-modal drawer has no scrim, so form and info behave the same.

Before:

<Drawer isOpen={isOpen} onOpenChange={setIsOpen} label="Details">
  <Section padding={4}>
    <Heading level={3}>Details</Heading>
    ...
  </Section>
</Drawer>

After:

<Drawer isOpen={isOpen} onOpenChange={setIsOpen} label="Details">
  <DrawerHeader title="Details" onOpenChange={setIsOpen} />
  <Section padding={4}>...</Section>
</Drawer>

Migration: Drawer is unreleased Lab, so there is no codemod. Remove hasCloseButton, and add DrawerHeader with onOpenChange wherever the built-in button was relied on.

Design and alternatives

DrawerHeader is Drawer-owned rather than a reuse of DialogHeader, for three reasons:

  • DialogHeader focuses its title on mount, before Drawer presents its native host.
  • DialogHeader names the dialog through aria-labelledby, while Drawer is named by its required label.
  • DialogHeader emits dialog-header theme targets.

Rejected alternatives:

  • Keep the built-in button and hide it only for required. This leaves Drawer different from Dialog.
  • Reuse DialogHeader, for the focus, naming, and theming reasons above.
  • Remove the button with no header. A non-modal drawer would then have no built-in way to show a close action.

Open question, recorded in the spec: should DrawerHeader give the drawer a default focus target and name it through aria-labelledby, as DialogHeader does for Dialog?

Evidence

  • Unit tests:
    • Drawer renders no close button of its own, modal or non-modal.
    • A DrawerHeader given the drawer's onOpenChange closes it.
    • purpose: info closes on Escape and scrim click; form ignores the scrim click; required ignores Escape, the native cancel event, and the scrim click; a required drawer stops Escape from reaching a sibling drawer behind it.
    • Roles: a modal required drawer is an alertdialog; a non-modal one stays a dialog.
    • DrawerHeader: the title is an h2; it has no close button without onOpenChange; the close button is named and calls onOpenChange(false); slot order; empty and 0 subtitles; all five theme targets; no focus on mount.
  • Mutation checks: making Escape always close, or ignoring purpose for scrim clicks, fails two tests each.
  • Real browser (Chromium, built Storybook):
    • info closes on Escape and on a scrim click.
    • form stays open on a scrim click and closes on Escape.
    • required is an alertdialog, stays open on Escape and on a scrim click, has no close button, and closes through its own Accept button.
    • The non-modal header close button closes the drawer, and the Showcase drawer has no built-in close button.
    • No page errors.
  • The existing drawer-close browser check (modal-close-visibility.js) passes for the modal, non-modal, and stacked-exit stories.

Scope

  • One capability is added: Dialog-aligned dismissal and close control for Drawer.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run packages/lab/src/Drawer packages/core/src/Layer: 232 passed.
  • pnpm -F @astryxdesign/docsite test: 580 passed, 6 skipped. Docsite typecheck passes.
  • Docsite generation: 280 components and 668 blocks. The shadcn route lock adds one route, components/lab/drawer-header; the six Drawer example routes are unchanged.
  • pnpm build, the Lab docs typecheck, the Storybook typecheck, pnpm check:repo, pnpm lab:readiness:check, pnpm visual:probe-theme:check, and astryx doctor integration validate for Lab all pass.
  • node .github/scripts/modal-close-visibility.js --storybook-dir apps/storybook/dist passes in Chromium.

Drawer drops its built-in close button and the hasCloseButton prop, and
adopts Dialog's purpose prop with the same values and default: info closes
on Escape and a scrim click, form closes on Escape only, and required
closes on neither, consumes Escape so it cannot reach a lower layer, and
exposes a modal drawer as an alertdialog.

A new DrawerHeader has DialogHeader's API (title, subtitle, start/end
content, divider) and renders a close button only when given onOpenChange.
Unlike DialogHeader it does not take focus on mount, since Drawer focuses
data-autofocus after native presentation, and it does not name the drawer.

Update the Drawer docs, examples, and runnable blocks to compose
DrawerHeader, add a Purpose story, refresh the shadcn route lock with the
DrawerHeader component route, and record the change as DEC-1 in the draft
Drawer spec.
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 2, 2026 3:28am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 2, 2026, 3:55 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 2, 2026
@imdreamrunner
imdreamrunner marked this pull request as ready for review October 2, 2026 00:37
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/lab N/A 3.8KB 1.6KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

15 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
SideNav Resizable in AppShell probe dark 3,208
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

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

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for aligning Drawer with Dialog — the dismissal mechanics, tests, and browser evidence are convincing, and the migration for an unreleased Lab component is clear.

Approval needs one maintainer decision first. Drawer on main is still a draft record, and this change proposes its DEC-1 decision — purpose with Dialog's values and default, removing the built-in close button and hasCloseButton, adding DrawerHeader, and adding the five drawer-header theme targets — with that decision marked pending approval. The current Dialog record governs Dialog's focus behavior only, and the shared overlay-dismissal family leaves a member's own dismissal and open-state choices to that member's record, so no current governing spec yet settles this Drawer delta. Could a maintainer provide or identify the governing spec for it (for example, by settling DEC-1 in the Drawer record)? No need to remove or split anything for this — approval simply waits on that decision.

One small, separate fix to make alongside it: the Storybook Showcase drawer no longer shows a visible close action now that the built-in button is gone. Composing DrawerHeader there, as the docsite blocks already do, would keep the first example consistent with the new guidance to give every drawer a visible way to close.

Everything else checked out: the shared-stack behavior matches the current family contract, the focused Drawer and Layer suites pass, the required drawer stays open on Escape and is exposed as an alert dialog in a real browser, and the change is a single coherent capability.

[Automated review]

The theming-targets test requires a directory's own doc to list every
astryx-* class rendered there. DrawerHeader lives in the Drawer directory,
so Drawer.doc.mjs lists its five drawer-header targets, the same way
Dialog.doc.mjs lists the dialog-header targets.

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for aligning Drawer with Dialog — the dismissal mechanics, tests, and browser evidence are convincing, and the migration for an unreleased Lab component is clear.

Approval needs one maintainer decision first. Drawer on main is still a draft record, and this change proposes its DEC-1 decision — purpose with Dialog's values and default, removing the built-in close button and hasCloseButton, adding DrawerHeader, and adding the five drawer-header theme targets — with that decision marked pending approval. The current Dialog record governs Dialog's focus behavior only, and the shared overlay-dismissal family leaves a member's own dismissal and open-state choices to that member's record, so no current governing spec yet settles this Drawer delta. Could a maintainer provide or identify the governing spec for it (for example, by settling DEC-1 in the Drawer record)? No need to remove or split anything for this — approval simply waits on that decision.

One small, separate fix to make alongside it: the Storybook Showcase drawer no longer shows a visible close action now that the built-in button is gone. Composing DrawerHeader there, as the docsite blocks already do, would keep the first example consistent with the new guidance to give every drawer a visible way to close.

Everything else checked out at this revision: the shared-stack behavior matches the current family contract, the focused Drawer and Layer suites pass, the required drawer stays open on Escape, and the change is a single coherent capability.

[Automated review]

With the built-in close button gone, the Showcase story composes
DrawerHeader with onOpenChange, matching the docsite blocks and the
guidance that every drawer has a visible way to close.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for aligning Drawer with Dialog — the dismissal mechanics, tests, and browser evidence are convincing, and the migration for an unreleased Lab component is clear.

Approval needs one maintainer decision first. Drawer on main is still a draft record, and this change proposes its DEC-1 decision — purpose with Dialog's values and default, removing the built-in close button and hasCloseButton, adding DrawerHeader, and adding the five drawer-header theme targets — with that decision marked pending approval. The current Dialog record governs Dialog's focus behavior only, and the shared overlay-dismissal family leaves a member's own dismissal and open-state choices to that member's record, so no current governing spec yet settles this Drawer delta. Could a maintainer provide or identify the governing spec for it (for example, by settling DEC-1 in the Drawer record)? No need to remove or split anything for this — approval simply waits on that decision.

Everything else checked out at this revision: the shared-stack behavior matches the current family contract, the focused Drawer and Layer suites pass (232 tests), the required drawer stays open on Escape as an alert dialog, and the Showcase story now shows a visible header close action. The change is a single coherent capability.

[Automated review]

@imdreamrunner
imdreamrunner merged commit 06c8fa3 into main Oct 2, 2026
45 checks passed
@github-actions
github-actions Bot deleted the feat/lab-drawer-align-dialog branch October 2, 2026 06:24
imdreamrunner added a commit that referenced this pull request Oct 8, 2026
The scrolling content area becomes a container publisher with Dialog's
contract: a padding prop on Dialog's spacing-step scale, theme padding on
'drawer' expanded to --astryx-drawer-padding* container tokens, and a
--spacing-4 default shared by the edge and Layout inset chains, exactly as
in Dialog. Headers compose as in Dialog: DrawerHeader sits in a Layout
header slot, and the Layout redistributes the inset to its regions, so the
header lines up with the body and is not inset twice. The docsite blocks,
stories, and doc snippets move to that composition, and padding={0} keeps a
full-bleed content area.

The two sandbox audit drawers still passed hasCloseButton, which #6877
removed, so their non-modal panels had no visible close button. They now
compose DrawerHeader with onOpenChange in a Layout header slot, keep the
title as the focus target on open and on row switch, and reset the
LayoutContent scroller when the selected row changes.

The block-end edge adds the home-indicator safe area on top of the
container inset in every mode, and the content area now paints the surface
so a dark-mode inset ring in --shadow-high no longer changes the panel edge
partway down (the #5305 treatment).

Core gains the drawer chains in container.stylex.ts, a drawer entry in
derivedVarRegistry (doc source of truth lives in packages/lab), and Layout
re-exports of the explicit-padding lowering maps that lab needs.
Drawer.spec.md records the contract as DEC-2 (owner decision) and FR16.
imdreamrunner added a commit that referenced this pull request Oct 8, 2026
The scrolling content area becomes a container publisher with Dialog's
contract: a padding prop on Dialog's spacing-step scale, theme padding on
'drawer' expanded to --astryx-drawer-padding* container tokens, and a
--spacing-4 default shared by the edge and Layout inset chains, exactly as
in Dialog. Headers compose as in Dialog: DrawerHeader sits in a Layout
header slot, and the Layout redistributes the inset to its regions, so the
header lines up with the body and is not inset twice. The docsite blocks,
stories, and doc snippets move to that composition, and padding={0} keeps a
full-bleed content area.

The two sandbox audit drawers still passed hasCloseButton, which #6877
removed, so their non-modal panels had no visible close button. They now
compose DrawerHeader with onOpenChange in a Layout header slot, keep the
title as the focus target on open and on row switch, and reset the
LayoutContent scroller when the selected row changes.

The block-end edge adds the home-indicator safe area on top of the
container inset in every mode, and the content area now paints the surface
so a dark-mode inset ring in --shadow-high no longer changes the panel edge
partway down (the #5305 treatment).

Core gains the drawer chains in container.stylex.ts and a drawer entry in
derivedVarRegistry (doc source of truth lives in packages/lab). Lab reads the
explicit-padding lowering maps from the existing
@astryxdesign/core/Layout/padding.stylex subpath, so the core root exports
are unchanged.
Drawer.spec.md records the contract as DEC-2 (owner decision) and FR16.
imdreamrunner added a commit that referenced this pull request Oct 9, 2026
The scrolling content area becomes a container publisher with Dialog's
contract: a padding prop on Dialog's spacing-step scale, theme padding on
'drawer' expanded to --astryx-drawer-padding* container tokens, and a
--spacing-4 default shared by the edge and Layout inset chains, exactly as
in Dialog. Headers compose as in Dialog: DrawerHeader sits in a Layout
header slot, and the Layout redistributes the inset to its regions, so the
header lines up with the body and is not inset twice. The docsite blocks,
stories, and doc snippets move to that composition, and padding={0} keeps a
full-bleed content area.

The two sandbox audit drawers still passed hasCloseButton, which #6877
removed, so their non-modal panels had no visible close button. They now
compose DrawerHeader with onOpenChange in a Layout header slot, keep the
title as the focus target on open and on row switch, and reset the
LayoutContent scroller when the selected row changes.

The block-end edge adds the home-indicator safe area on top of the
container inset in every mode, and the content area now paints the surface
so a dark-mode inset ring in --shadow-high no longer changes the panel edge
partway down (the #5305 treatment).

Core gains the drawer chains in container.stylex.ts and a drawer entry in
derivedVarRegistry (doc source of truth lives in packages/lab). Lab reads the
explicit-padding lowering maps from the existing
@astryxdesign/core/Layout/padding.stylex subpath, so the core root exports
are unchanged.
Drawer.spec.md records the contract as DEC-2 (owner decision) and FR16.

This branch was successfully deployed

1 active deployment
Preview — 5c58a0df Deployed Oct 2, 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.

1 participant