Repository navigation
feat(lab): align Drawer dismissal and close control with Dialog - #6877
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
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.
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.
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.
User need
Builders who know Dialog expect Drawer to dismiss and close the same way, and today it does not:
purpose.hasCloseButton={false}, and its docs tell builders to leave clearance for it in their own header row. Dialog has no built-in button:DialogHeaderrenders one in the title row only when givenonOpenChange.Aligning the two before Drawer is promoted out of Lab means a Dialog user already knows the Drawer API.
Problem and solution fit
purposeon Drawer, with Dialog's values and default. It is the missing dismissal control. BottomSheet already reuses the same type.hasCloseButtonremoved. This is the difference from Dialog.DrawerHeader, withDialogHeader'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.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 staysdraft, sospec-owner-approvaldoes not need an owner comment.purposeuses the existingclose/blockEscape behavior offamily:overlay-dismissal; no family change is needed.Public delta and caller burden
hasCloseButton(defaulttrue)DrawerHeaderrenders one when givenonOpenChangehasCloseButtonpurpose'required' | 'form' | 'info', default'info', same as DialogDrawer,DrawerPropsDrawerHeader,DrawerHeaderPropsastryx-drawerastryx-drawer-header,-start-content,-title-block,-end-content,-close-iconpurposebehavior: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 getsrole="alertdialog".formandinfobehave the same.Before:
After:
Migration: Drawer is unreleased Lab, so there is no codemod. Remove
hasCloseButton, and addDrawerHeaderwithonOpenChangewherever the built-in button was relied on.Design and alternatives
DrawerHeaderis Drawer-owned rather than a reuse ofDialogHeader, for three reasons:DialogHeaderfocuses its title on mount, before Drawer presents its native host.DialogHeadernames the dialog througharia-labelledby, while Drawer is named by its requiredlabel.DialogHeaderemitsdialog-headertheme targets.Rejected alternatives:
required. This leaves Drawer different from Dialog.DialogHeader, for the focus, naming, and theming reasons above.Open question, recorded in the spec: should
DrawerHeadergive the drawer a default focus target and name it througharia-labelledby, asDialogHeaderdoes for Dialog?Evidence
DrawerHeadergiven the drawer'sonOpenChangecloses it.purpose:infocloses on Escape and scrim click;formignores the scrim click;requiredignores Escape, the nativecancelevent, and the scrim click; arequireddrawer stops Escape from reaching a sibling drawer behind it.requireddrawer is analertdialog; a non-modal one stays adialog.DrawerHeader: the title is an h2; it has no close button withoutonOpenChange; the close button is named and callsonOpenChange(false); slot order; empty and0subtitles; all five theme targets; no focus on mount.purposefor scrim clicks, fails two tests each.infocloses on Escape and on a scrim click.formstays open on a scrim click and closes on Escape.requiredis analertdialog, stays open on Escape and on a scrim click, has no close button, and closes through its own Accept button.modal-close-visibility.js) passes for the modal, non-modal, and stacked-exit stories.Scope
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.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, andastryx doctor integration validatefor Lab all pass.node .github/scripts/modal-close-visibility.js --storybook-dir apps/storybook/distpasses in Chromium.