Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4713e34
feat(Popover): presentation — a BottomSheet on a phone when asked, as…
vjeux Oct 24, 2026
c4a2b14
Merge remote-tracking branch 'origin/main' into vjeux/pr-8229
cixzhang Oct 25, 2026
fe78c6b
fix(Popover): the sheet takes caller styling, compact follows the com…
cixzhang Oct 25, 2026
0a53fa1
fix(Popover): an adaptive sheet closed after a turn plays its exit an…
vjeux Oct 25, 2026
fc908db
fix(Popover): one presentation at a time, and nothing of the sheet at…
vjeux Oct 25, 2026
ca08632
fix(Popover): the trigger's ARIA wiring follows the mounted sheet
vjeux Oct 25, 2026
7277490
fix(Popover): the closed sheet keeps the content's state, and the tri…
vjeux Oct 25, 2026
b1c605f
fix(BottomSheet): a closed sheet that stays mounted observes nothing …
cixzhang Oct 25, 2026
61fdbc6
fix(Popover): record the touch sheet in the anatomy; the sheet's fall…
cixzhang Oct 25, 2026
dccb388
fix(Popover): record the required sheet's INV7 exception; its reveale…
vjeux Oct 25, 2026
fca2db5
Merge main 17fead75b9 (component:Popover DEC-6, current)
vjeux Oct 25, 2026
c7595bb
fix(Popover): a sheet without light dismiss shows a Close button a fi…
cixzhang Oct 25, 2026
1006494
fix(BottomSheet): the frame drops its positioner, pill and tint elements
vjeux Oct 25, 2026
5645711
chore: changeset for BottomSheet's three fewer elements
vjeux Oct 25, 2026
c9ed400
fix(Popover): the sheet always light-dismisses and is always named (D…
cixzhang Oct 25, 2026
e561e4f
spec(Popover): DEC-8's decider is cixzhang, 2026-10-25
cixzhang Oct 25, 2026
a3a9762
Merge main (8c3f3be) into the Popover presentation
cixzhang Oct 25, 2026
302e5cc
fix(Popover): nested sheets keep Escape, render-prop triggers name th…
cixzhang Oct 25, 2026
21a9706
docs(BottomSheet): a switcher sheet's positioner has its own element job
cixzhang Oct 26, 2026
787fd0b
fix(Popover): focus enters the sheet on the first content control (FR2)
cixzhang Oct 26, 2026
6178a62
fix(BottomSheet): data-autofocus wins over the panel showModal focused
cixzhang Oct 26, 2026
594ac1c
fix(BottomSheet, Popover): the edge tint stays its own element; Popov…
cixzhang Oct 26, 2026
131c988
fix(Popover): the sheet's focus entry skips BottomSheet's scroll area…
cixzhang Oct 26, 2026
e57d3b6
fix(Popover): export the PopoverPresentation type
cixzhang Oct 26, 2026
5128751
docs(layer-runtime): Popover's sheet presentation hold is a named INV…
cixzhang Oct 26, 2026
c50904c
Merge main (3ab7f32dbe8) into the Popover presentation
cixzhang Oct 26, 2026
268fa9b
docs(layer-runtime): Popover's sheet presentation hold is a named INV…
cixzhang Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/bottom-sheet-fewer-elements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[fix] BottomSheet renders fewer elements, with no visual change: an open sheet's dialog positions the panel itself, the grab bar draws its pill, and a closed sheet renders no edge tint. A switcher's sheets keep their positioner.

@vjeux
7 changes: 7 additions & 0 deletions .changeset/popover-presentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feature] Popover takes `presentation`, with the values DropdownMenu and Selector use: `'popover'` (the default, unchanged) anchors it to its trigger, `'bottom-sheet'` presents its content in a modal BottomSheet labeled by `label`, and `'adaptive'` uses the BottomSheet on a compact touch screen (a phone) and the anchored popover elsewhere, the way iOS presents a popover on an iPhone. Compact is the theme's compact definition: narrower than its `md` width point or shorter than 500 px. In a sheet, `placement`, `alignment`, `width`, `role`, `isModal` and `hasAutoFocus` do not apply, and `xstyle`, `className` and `style` style the sheet's panel. The sheet loads only when a popover can present one.

@vjeux
25 changes: 25 additions & 0 deletions apps/storybook/stories/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,31 @@ export const BottomSheetPresentationOption: Story = {
},
};

export const AdaptivePresentation: Story = {
name: 'Adaptive Presentation',
parameters: {
layout: 'fullscreen',
docs: {
story: {inline: false, height: '844px'},
description: {
story:
'presentation="adaptive": on a compact touch screen (a phone) the content is presented in a BottomSheet, the way iOS presents a popover on an iPhone; with a mouse or on a larger screen it stays anchored to its trigger.',
},
},
},
render: () => (
<div style={{padding: 16}}>
<Popover
label="Filter by status"
presentation="adaptive"
width={280}
content={<FilterContent />}>
<Button label="Filter">Filter</Button>
</Popover>
</div>
),
};

export const AdaptivePopoverRecipe: PresentationRecipeStory = {
name: 'Adaptive Popover Recipe',
args: {
Expand Down
22 changes: 14 additions & 8 deletions packages/core/src/BottomSheet/BottomSheet.spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,23 @@ in `BottomSheet.doc.mjs`.
- Element jobs (`architecture:component-style-authoring` INV7; the
open-layer allowance of `spec:AST-017` FR60, DEC-29). An open sheet's frame
has these elements, each with one job:
- the dialog carries the sheet's dialog role, and modality and the top
layer when the sheet is modal;
- the positioner holds the panel at the block end;
- the dialog carries the sheet's dialog role, modality and the top layer
when the sheet is modal, and holds the panel at the block end with its
own grid;
- the panel paints the `bottom-sheet` target;
- the grabber bar is the drag handle, and its pill draws the handle;
- the grabber bar is the drag handle, and its `::before` draws the handle;
- the body is the scroll area;
- the content box carries the padding and is the observed content box (FR3);
- the edge tint gives iOS Safari's toolbar the sheet's color.
- Fewer is preferred: the pill and the edge tint are decoration that should
move to pseudo-elements, and the positioner should merge into the panel;
each is an open gap.
- the edge tint gives iOS Safari's toolbar the sheet's color: its own
element outside the panel's transform, so it stays flush with the
viewport's bottom edge at every detent, rendered only while the sheet is
presented;
- in a BottomSheetSwitcher, each sheet's positioner holds its panel at the
block end and hides a sheet that is not presented, so one dialog can
switch between sheets.
- The handle's pill is a pseudo-element and a standalone sheet's dialog holds
the panel in place, so a standalone sheet's frame has no positioner or pill
element of its own.
- Elements a presenting component adds beyond this frame are its own to
justify.

Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/BottomSheet/BottomSheet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {describe, it, expect, vi, beforeEach, afterEach} from 'vitest';
import {act, render, screen, fireEvent} from '@testing-library/react';
import {createRef, useState} from 'react';
import {BottomSheet} from './BottomSheet';
import {BottomSheetEscapeContext} from './bottomSheetEscape';
import {BottomSheetSwitcher} from './BottomSheetSwitcher';
import {__resetInteractionModalityForTest} from '../utils/interactionModality';

Expand Down Expand Up @@ -498,6 +499,28 @@ describe('BottomSheet', () => {
expect(dialog).toHaveStyle({'--_sheet-scrim-opacity': '1'});
});

it("the internal Escape gate (Popover's sheet) blocks Escape and the close request, not the scrim or swipe", () => {
const onOpenChange = vi.fn();
render(
<BottomSheetEscapeContext value={false}>
<BottomSheet isOpen onOpenChange={onOpenChange} label="Filters">
Content
</BottomSheet>
</BottomSheetEscapeContext>,
);
const dialog = screen.getByRole('dialog');

fireEvent.keyDown(dialog, {key: 'Escape'});
fireEvent(dialog, new Event('cancel', {cancelable: true}));
expect(onOpenChange).not.toHaveBeenCalled();

fireEvent.click(dialog);
expect(onOpenChange).toHaveBeenCalledTimes(1);
drag(getHandle(), [{y: 0}, {y: 40}, {y: 120}]);
expect(onOpenChange).toHaveBeenCalledTimes(2);
expect(onOpenChange).toHaveBeenNthCalledWith(2, false);
});

it('stays open when a file picker inside it is dismissed, and still closes on its own close request', () => {
// A file input fires a bubbling `cancel` at itself when its picker is
// dismissed. It reaches the <dialog> like a close request but is not one.
Expand Down
69 changes: 46 additions & 23 deletions packages/core/src/BottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {

export type {BottomSheetHeight, BottomSheetSnapPoint} from './BottomSheetPanel';
import type {BottomSheetHeight, BottomSheetSnapPoint} from './BottomSheetPanel';
import {BottomSheetEscapeContext} from './bottomSheetEscape';

const styles = stylex.create({
dialog: {
Expand All @@ -101,6 +102,15 @@ const styles = stylex.create({
dialogOpen: {
display: 'block',
},
// An open standalone dialog is its panel's positioner: the panel sits at its
// block end, centred, with no wrapper between them
// (architecture:component-style-authoring INV7). A tap beside a narrower
// panel lands on the dialog itself, which light dismiss reads.
dialogPanelHost: {
display: 'grid',
alignContent: 'end',
justifyItems: 'center',
},
dialogNonModal: {
pointerEvents: 'none',
zIndex: 1000,
Expand Down Expand Up @@ -332,11 +342,13 @@ function StandaloneBottomSheet({
? {kind: 'exiting'}
: {kind: 'hidden'};

// Popover's sheet may turn Escape off on its own (bottomSheetEscape.ts).
const isEscapeAllowed = use(BottomSheetEscapeContext);
const dismissOnEscape = useCallback(() => {
if (isOpen && purpose !== 'required') {
if (isOpen && purpose !== 'required' && isEscapeAllowed) {
onOpenChange(false);
}
}, [isOpen, onOpenChange, purpose]);
}, [isEscapeAllowed, isOpen, onOpenChange, purpose]);
const dismissOnLightInteraction = useCallback(() => {
if (purpose === 'info') {
onOpenChange(false);
Expand Down Expand Up @@ -432,7 +444,8 @@ function StandaloneBottomSheet({
// rather than letting it close a layer behind it. `required` blocks too.
const {shouldDismissOnCloseRequest} = useLayerDismissal({
isActive: shouldPresent,
escapeBehavior: isOpen && purpose !== 'required' ? 'close' : 'block',
escapeBehavior:
isOpen && purpose !== 'required' && isEscapeAllowed ? 'close' : 'block',
onDismiss: dismissOnEscape,
getContainer: () => dialogRef.current,
isPresent: () => dialogRef.current?.open ?? false,
Expand Down Expand Up @@ -470,6 +483,7 @@ function StandaloneBottomSheet({
{...stylex.props(
styles.dialog,
shouldPresent && styles.dialogOpen,
shouldPresent && styles.dialogPanelHost,
hasScrim && styles.scrim,
hasScrim && !isOpen && isPresented && styles.scrimClosing,
!hasScrim && styles.dialogNonModal,
Expand All @@ -482,25 +496,29 @@ function StandaloneBottomSheet({
inert={!isOpen && isPresented ? true : undefined}
onCancel={handleCancel}
onClick={handleClick}>
<div {...stylex.props(styles.positioner)}>
<BottomSheetPanel
{...props}
ref={ref}
state={panelState}
height={height}
label={label}
snapPoints={snapPoints}
isSwipeDismissAllowed={purpose === 'info'}
isPageScrollLocked={shouldPresent && hasScrim}
xstyle={xstyle}
onDismiss={dismissOnLightInteraction}
onScrimOpacity={handleScrimOpacity}
onElementChange={handlePanelElementChange}
onMotionComplete={handleMotionComplete}>
<LayerDepthProvider>{children}</LayerDepthProvider>
</BottomSheetPanel>
</div>
<BottomSheetEdgeTint />
<BottomSheetPanel
{...props}
ref={ref}
state={panelState}
height={height}
label={label}
snapPoints={snapPoints}
isSwipeDismissAllowed={purpose === 'info'}
isPageScrollLocked={shouldPresent && hasScrim}
xstyle={xstyle}
onDismiss={dismissOnLightInteraction}
onScrimOpacity={handleScrimOpacity}
onElementChange={handlePanelElementChange}
onMotionComplete={handleMotionComplete}>
<LayerDepthProvider>
{/* A sheet opened inside this one starts from Escape on. */}
<BottomSheetEscapeContext value>{children}</BottomSheetEscapeContext>
</LayerDepthProvider>
</BottomSheetPanel>
{/* Its own element, outside the panel's transform, so it stays flush
with the viewport's bottom edge at every detent; only while the
sheet is presented, so a closed sheet renders no extra element. */}
{shouldPresent && <BottomSheetEdgeTint />}
</dialog>
);
}
Expand Down Expand Up @@ -805,7 +823,12 @@ function SwitcherBottomSheetItem({
fresh ownership scope so a nested BottomSheet is standalone unless
it establishes a nested BottomSheetSwitcher of its own. */}
<BottomSheetSwitcherContext value={null}>
<LayerDepthProvider>{children}</LayerDepthProvider>
<LayerDepthProvider>
{/* A sheet opened inside this one starts from Escape on. */}
<BottomSheetEscapeContext value>
{children}
</BottomSheetEscapeContext>
</LayerDepthProvider>
</BottomSheetSwitcherContext>
</BottomSheetPanel>
</div>
Expand Down
123 changes: 77 additions & 46 deletions packages/core/src/BottomSheet/BottomSheetPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,15 @@ const styles = stylex.create({
default: 'grab',
':is(:disabled,[aria-disabled="true"])': 'default',
},
},
handlePill: {
width: sizeVars['--size-element-lg'],
height: spacingVars['--spacing-1'],
borderRadius: radiusVars['--radius-full'],
backgroundColor: colorVars['--color-border'],
// The pill, drawn on the grab bar itself: decoration with no role of its
// own (architecture:component-style-authoring INV7).
'::before': {
content: '""',
width: sizeVars['--size-element-lg'],
height: spacingVars['--spacing-1'],
borderRadius: radiusVars['--radius-full'],
backgroundColor: colorVars['--color-border'],
},
},
body: {
flexGrow: 1,
Expand Down Expand Up @@ -316,6 +319,19 @@ interface BottomSheetPanelProps extends BaseProps<HTMLDivElement> {
onMotionComplete?: (motion: BottomSheetPanelMotion) => void;
}

/**
* A hidden sheet observes nothing (component:Popover PR1, FR5): the scroll
* area's measuring ref attaches as the sheet presents and detaches once it is
* hidden again, so a closed sheet that stays mounted holds no resize,
* mutation or viewport observers.
*/
function whilePresented<P extends {ref?: unknown}>(
isPresented: boolean,
props: P,
): P {
return isPresented ? props : {...props, ref: undefined};
}

function motionForState(
state: BottomSheetPanelState,
): BottomSheetPanelMotion | null {
Expand Down Expand Up @@ -543,14 +559,24 @@ export function BottomSheetPanel({
stickyContainment: 'always',
});

// The sheet measures its own height only while it is presented; a hidden
// sheet that stays mounted observes nothing.
const isPresentedRef = useRef(isPresented);
const setElement = useCallback(
(element: HTMLDivElement | null) => {
sheetRef(element);
sheetRef(isPresentedRef.current ? element : null);
elementRef.current = element;
onElementChange?.(element);
},
[onElementChange, sheetRef],
);
useLayoutEffect(() => {
if (isPresentedRef.current === isPresented) {
return;
}
isPresentedRef.current = isPresented;
sheetRef(isPresented ? elementRef.current : null);
}, [isPresented, sheetRef]);
useMobileKeyboard({
bodyRef: bodyElementRef,
bottomClearance: MOBILE_KEYBOARD_BOTTOM_CLEARANCE,
Expand Down Expand Up @@ -736,49 +762,54 @@ export function BottomSheetPanel({
<div
{...stylex.props(styles.handleBar)}
{...handleProps}
aria-hidden="true">
<div {...stylex.props(styles.handlePill)} />
</div>
aria-hidden="true"
/>
<div
{...getViewportProps<HTMLDivElement>({
...bodyProps,
...mergeProps(
stylex.props(
focusOutlineStyles.focusVisible,
styles.body,
height === 'tall' && styles.tallKeyboardBody,
{...whilePresented(
isPresented,
getViewportProps<HTMLDivElement>({
...bodyProps,
...mergeProps(
stylex.props(
focusOutlineStyles.focusVisible,
styles.body,
height === 'tall' && styles.tallKeyboardBody,
),
scrollPreservationInset > 0
? {style: {paddingBlockEnd: `${scrollPreservationInset}px`}}
: {},
),
scrollPreservationInset > 0
? {style: {paddingBlockEnd: `${scrollPreservationInset}px`}}
: {},
),
})}>
}),
)}>
<div
{...getContentProps<HTMLDivElement>(
stylex.props(
styles.content,
...container(
usesThemePadding
? {useThemeDefault: 'bottom-sheet'}
: {
paddingInnerX: paddingToken,
paddingInnerY: paddingToken,
paddingOuterX: paddingToken,
paddingOuterY: paddingToken,
},
{...whilePresented(
isPresented,
getContentProps<HTMLDivElement>(
stylex.props(
styles.content,
...container(
usesThemePadding
? {useThemeDefault: 'bottom-sheet'}
: {
paddingInnerX: paddingToken,
paddingInnerY: paddingToken,
paddingOuterX: paddingToken,
paddingOuterY: paddingToken,
},
),
!usesThemePadding &&
effectivePadding !== 4 &&
paddingStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingInlineVarStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingBlockStartVarStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingBlockEndVarStyles[effectivePadding],
),
!usesThemePadding &&
effectivePadding !== 4 &&
paddingStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingInlineVarStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingBlockStartVarStyles[effectivePadding],
!usesThemePadding &&
effectivePadding !== 4 &&
containerPaddingBlockEndVarStyles[effectivePadding],
),
)}>
<LayerContentBoundary>{children}</LayerContentBoundary>
Expand Down
Loading
Loading