Skip to content

Commit 2582a33

Browse files
committed
feat(Popover): presentation — a BottomSheet on a phone when asked, as iOS presents a popover
Popover takes `presentation` with the values DropdownMenu, ContextMenu, MoreMenu, Selector and MultiSelector use. 'popover', the default, keeps the released anchored surface. 'bottom-sheet' presents the content in a modal BottomSheet labeled by `label`, at the sheet's tall height, inset by `padding`. 'adaptive' presents that sheet on a compact touch screen and the anchored popover elsewhere, which is how iOS presents a popover on an iPhone unless the app keeps it anchored. In a sheet, placement, alignment and width do not apply; light dismiss maps to the sheet's purpose (info, form without light dismiss, required with neither). The surface is chosen when the popover opens and stays until it closes; the trigger's expanded state and controlled element follow it. The sheet loads on demand (lazyPopoverBottomSheet), as DropdownMenu's does. component:Popover gains the Presentation concept and DEC-6, pending owner review, and OQ1 asks whether 'adaptive' becomes the default.
1 parent 0ade0dd commit 2582a33

7 files changed

Lines changed: 510 additions & 15 deletions

File tree

‎.changeset/popover-presentation.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[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. In a sheet, `placement`, `alignment` and `width` do not apply. The sheet loads only when a popover can present one.
6+
7+
@vjeux

‎apps/storybook/stories/Popover.stories.tsx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,31 @@ export const BottomSheetPresentationOption: Story = {
863863
},
864864
};
865865

866+
export const AdaptivePresentation: Story = {
867+
name: 'Adaptive Presentation',
868+
parameters: {
869+
layout: 'fullscreen',
870+
docs: {
871+
story: {inline: false, height: '844px'},
872+
description: {
873+
story:
874+
'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.',
875+
},
876+
},
877+
},
878+
render: () => (
879+
<div style={{padding: 16}}>
880+
<Popover
881+
label="Filter by status"
882+
presentation="adaptive"
883+
width={280}
884+
content={<FilterContent />}>
885+
<Button label="Filter">Filter</Button>
886+
</Popover>
887+
</div>
888+
),
889+
};
890+
866891
export const AdaptivePopoverRecipe: PresentationRecipeStory = {
867892
name: 'Adaptive Popover Recipe',
868893
args: {

‎packages/core/src/Popover/Popover.doc.mjs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ export const docs = {
149149
'Whether pressing Escape dismisses the popover. Only takes full effect together with hasLightDismiss={false}, since native light dismiss also closes on Escape.',
150150
default: 'true',
151151
},
152+
{
153+
name: 'presentation',
154+
type: "'popover' | 'bottom-sheet' | 'adaptive'",
155+
description:
156+
"The surface that holds the content. 'popover' anchors it to the trigger, 'bottom-sheet' presents it in a modal BottomSheet labeled by label, and 'adaptive' uses the BottomSheet on a compact touch screen (a phone) and the anchored popover elsewhere. In a sheet, placement, alignment and width do not apply.",
157+
default: "'popover'",
158+
},
152159
{
153160
name: 'xstyle',
154161
type: 'StyleXStyles',
@@ -397,6 +404,13 @@ export const docsZh = {
397404
'按 Escape 是否关闭弹出框。仅在 hasLightDismiss={false} 时生效,因为原生 light dismiss 行为同样响应 Escape。',
398405
default: 'true',
399406
},
407+
{
408+
name: 'presentation',
409+
type: "'popover' | 'bottom-sheet' | 'adaptive'",
410+
description:
411+
"承载内容的界面。'popover' 锚定在触发器上,'bottom-sheet' 以模态 BottomSheet 呈现(由 label 命名),'adaptive' 在紧凑触屏(手机)上使用 BottomSheet,在其他设备上使用锚定的弹出框。在底部面板中,placement、alignment 和 width 不生效。",
412+
default: "'popover'",
413+
},
400414
],
401415
},
402416
],
@@ -573,6 +587,8 @@ export const docsDense = {
573587
'Outside click dismisses; false for explicit-dismiss surfaces (coachmarks).',
574588
hasEscapeDismiss:
575589
'Escape dismisses; full effect only with hasLightDismiss=false.',
590+
presentation:
591+
"Surface: 'popover' (anchored), 'bottom-sheet' (modal BottomSheet), or 'adaptive' (BottomSheet on a compact touch screen, popover elsewhere).",
576592
},
577593
},
578594
],

‎packages/core/src/Popover/Popover.spec.md‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ verified_by:
1616
packages/core/src/Popover/Popover.doc.mjs,
1717
packages/core/src/Popover/usePopover.doc.mjs,
1818
packages/core/src/hooks/useFocusTrap.test.tsx,
19+
packages/core/src/Popover/PopoverPresentation.test.tsx,
1920
packages/cli/foundation/discovery/theming-targets.mjs,
2021
packages/cli/foundation/discovery/theming-targets.test.mjs,
2122
scripts/check-knowledge.mjs,
@@ -124,6 +125,7 @@ surface, not the Layer entry point. There is no installable
124125
| Surface padding | A spacing-scale step, `0` through `10` | Sets the inset the painted surface keeps around caller content; `0` is a flush surface for content that owns its own edges | Popover and hook | Popover: step 3; hook: none | `component:Popover` | Pending owner review (DEC-4) | The rung lands on the painted surface, so a theme's `padding` on the `popover` target replaces it rather than nesting; consumer `xstyle` merges after it. |
125126
| Surface target ownership | Shared baseline or component-specific refinement | Assigns `popover` as the broad surface owner and lets a composed component add its own target on that same element | Popover and hook | `popover` baseline; no component-specific refinement | `component:Popover`; the composed component owns its refinement target | Current compatibility contract | `popover-surface` is compatibility output, not a new target for consumers or a second anatomy owner. |
126127
| Placement and preferred size | Logical placement/alignment plus preferred width | Positions the anchor surface and states the size Popover prefers; the layer runtime fits it to the viewport | Popover and hook renderer | Below/start; Popover matches trigger minimum width when no width is supplied | `component:Popover` for the preference; `architecture:layer-runtime` for the fit | Current public behavior | An explicit width renders at its size up to the viewport minus gutters; it is never shrunk to the room beside the trigger (`spec:AST-059` FR2). |
128+
| Presentation | `popover`, `bottom-sheet`, or `adaptive` | Chooses the surface that holds the content: anchored, a BottomSheet, or a BottomSheet on a compact touch screen | Popover | `popover` | `component:Popover`; `component:BottomSheet` owns the sheet | Pending owner review (DEC-6) | In a sheet, placement, alignment and width do not apply; the surface is chosen when it opens and stays until it closes. |
127129

128130
### Public `usePopover` semantic inputs
129131

@@ -331,6 +333,7 @@ consumers that need distinct theme reachability provide and document an owned
331333
| FR5 | `Popover.test.tsx` scheduling and observer-lifecycle suites | Closed, opened, repeated signals, cleanup | Constructing observers while closed or measuring more than once per pending frame fails lifecycle assertions. | `audit:Popover/resources` |
332334
| FR6, FR7 and theming anatomy | `Popover.test.tsx`, `Popover.doc.mjs`, `usePopover.doc.mjs`, `astryx theme targets Popover --json`, and `scripts/check-knowledge.mjs` | One real surface with canonical `popover` plus composed-component refinements | A fake anatomy part, missing canonical output, or an active target without a real owner fails review or validation. | `audit:Popover/theming` |
333335
| AR5 | `Popover.stories.tsx` manual-AT fixture and PR #5373 test record | Read-only dialog manual-AT fixture; no recorded NVDA/VoiceOver announcement result | A fixture without recorded AT/browser observations cannot be cited as announcement proof. | `audit:Popover/at-evidence` |
336+
| Presentation (DEC-6) | `PopoverPresentation.test.tsx` | Default on a phone, adaptive on a phone and a desktop, forced sheet, close, controlled, dismissal mapping | A sheet on a default phone popover, an anchored popover where the sheet is asked for, or a trigger state that ignores the sheet fails. | `audit:Popover/api` |
334337

335338
## Decision log
336339

@@ -391,6 +394,29 @@ Rejected: moving focus to the dialog surface on every pointer opening solely to
391394
avoid a keyboard-looking outline. That mixes visual modality with semantic focus
392395
placement and bypasses the shared focus-indication owner.
393396

397+
### DEC-6 — Presentation: the anchored popover, a sheet, or adaptive
398+
399+
**Reference:** `component:Popover/DEC-6`
400+
401+
**Decider:** pending owner review
402+
403+
Popover takes `presentation` with the vocabulary DropdownMenu, ContextMenu,
404+
MoreMenu, Selector and MultiSelector already use (`popover | bottom-sheet |
405+
adaptive`). `popover`, the default and the released behavior, anchors the
406+
surface to the trigger. `bottom-sheet` presents the content in a modal
407+
BottomSheet labeled by Popover's `label`, at the sheet's tall height and inset
408+
by Popover's `padding`. `adaptive` presents that sheet on a compact touch
409+
screen (the shared compact-touch query) and the anchored popover elsewhere,
410+
which is how iOS presents a popover on an iPhone unless the app keeps it: a
411+
sheet the height of the screen below the status bar.
412+
413+
In a sheet, `placement`, `alignment` and `width` do not apply, and dismissal
414+
maps to the sheet's purpose: `info` with light dismiss, `form` without it
415+
(Escape still closes), `required` with neither. The surface is chosen when the
416+
popover opens and stays until it closes, and the trigger's expanded state and
417+
controlled element follow whichever surface is open. The sheet loads on
418+
demand, so pages whose popovers stay anchored do not load it.
419+
394420
## Verification gaps
395421

396422
These implementation and evidence items remain required follow-up, but they do
@@ -408,9 +434,14 @@ not block acceptance of the semantic contract above.
408434

409435
## Open questions
410436

411-
None. DEC-1 settles the visibility model, DEC-2 settles canonical target
412-
ownership, and DEC-3 settles semantic focus versus modality-aware indication.
413-
The remaining items are verification work, not human API questions.
437+
DEC-1 settles the visibility model, DEC-2 settles canonical target ownership,
438+
and DEC-3 settles semantic focus versus modality-aware indication.
439+
440+
- **OQ1 — Default presentation.** iOS adapts a popover to a sheet on a phone
441+
unless the app keeps it anchored; Popover keeps `popover` as its default
442+
(DEC-6), so a phone shows the anchored popover unless the caller asks for
443+
`adaptive`. Whether `adaptive` becomes the default is the owner's decision:
444+
it changes a released interaction on phones.
414445

415446
## Content boundary
416447

0 commit comments

Comments
 (0)