Skip to content
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
62c9b4a
feat(AlertDialog): under a finger the alert appears the way iOS's does
vjeux Nov 3, 2026
dd1c162
Merge branch 'main' into uikit/c18-alerts-pr2
cixzhang Nov 5, 2026
c7f3449
Merge branch 'main' into uikit/c18-alerts-pr2
vjeux Nov 5, 2026
b86bb05
Merge main into the Toast branch (#8047 landed)
cixzhang Nov 6, 2026
c048c03
fix(Toast): a moved toast's card starts no transition
vjeux Nov 6, 2026
9cbf06b
Merge #10223 (a moved toast's card starts no transition) into uikit/c…
vjeux Nov 6, 2026
d244534
Merge main into the Toast branch (#10223 landed)
cixzhang Nov 6, 2026
d0f8d96
test(AlertDialog): a toast the alert raises enters once across repeats
vjeux Nov 6, 2026
773374e
docs(AlertDialog): split the file header's input list into sentences
vjeux Nov 6, 2026
d05b6c6
Merge main into the AlertDialog branch
vjeux Nov 6, 2026
f664bbc
fix(core): a leaving alert reads another window's nodes
vjeux Nov 6, 2026
362ea7f
test(AlertDialog): a toast the alert raises stays painted as it closes
vjeux Nov 6, 2026
91cb191
refactor(AlertDialog): keep the start scale's Effect note above it
vjeux Nov 6, 2026
d9bdee4
docs(AlertDialog): name the file header's inputs in one sentence
vjeux Nov 6, 2026
008be81
Merge main into the AlertDialog branch
vjeux Nov 7, 2026
057a36f
test(SnapPaging): the pager may bundle the input hold's host registry
vjeux Nov 7, 2026
95c6e98
docs(AlertDialog): shorter file headers, an exact WebKit skip reason
vjeux Nov 7, 2026
52802e3
fix(AlertDialog): close at the tap, fade an exit copy
vjeux Nov 7, 2026
fae82ea
Merge main into the AlertDialog branch
vjeux Nov 8, 2026
3ec5192
chore(sandbox): AlertDialog cases on a page the document scrolls
vjeux Nov 8, 2026
b68d8bf
Merge main into the AlertDialog branch
vjeux Nov 8, 2026
1589e5f
docs(AlertDialog): the touch exit still fades under reduced motion
vjeux Nov 8, 2026
bead618
Merge main into the AlertDialog branch
vjeux Nov 8, 2026
31e5375
Merge main into the AlertDialog branch
vjeux Nov 9, 2026
3e53941
Merge main into the AlertDialog branch
vjeux Nov 9, 2026
77caa21
fix(Layer): a hold leaves a live region with nothing focusable live
vjeux Nov 9, 2026
3393a18
docs(AlertDialog): the changeset says which announcements are read
vjeux Nov 9, 2026
5ee2465
docs(AlertDialog): reword the start limit's comment as two sentences
vjeux Nov 9, 2026
0e9f63a
Merge main into the AlertDialog branch
vjeux Nov 9, 2026
643313e
docs(AlertDialog): the changeset no longer says a toast is read at once
vjeux Nov 9, 2026
e30bc88
fix(Layer): a swizzled copy's input hold sees the package's hosts
vjeux Nov 9, 2026
0b033bc
Merge main
vjeux Nov 10, 2026
ec87860
refactor(Layer): the global modal hosts take a page-wide shared slot
vjeux Nov 10, 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/alertdialog-touch-motion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[feat] AlertDialog: under a finger the alert appears the way an iOS alert does. It scales down into place from 1.2 while it and the dimming fade in, on your theme's dialog entrance duration and curve. When it closes, it fades out with the dimming. With reduced motion it fades in without the scale, over 200 ms, and fades out within 200 ms. While it fades out, its content is inert: a touch, a click, a key or an assistive-technology activation on it does nothing, and focus leaves it until it returns to the opener. A toast stays operable above it, so one the action raises takes a tap and is read at once. On a phone, an alert with no `width` prop is now UIKit's 320 px wide in every theme, not 400 px. A `width` you pass still wins. With a mouse nothing changes.

@vjeux
1 change: 1 addition & 0 deletions apps/sandbox/scripts/next-export-routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"/",
"/404/",
"/components-patterns/",
"/pages/alert-dialog-cases/",
"/pages/butter-palette/",
"/pages/chat-layout/",
"/pages/codeblock-perf/",
Expand Down
32 changes: 32 additions & 0 deletions apps/sandbox/src/app/(raw)/pages/alert-dialog-cases/caseIds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

/**
* @file caseIds.ts
* @input None
* @output The AlertDialog case ids, their labels, and the parser for `?case=`
* @position Shared by the AlertDialog cases page and its cases.
*
* SYNC: A new case needs a component in cases.tsx.
*/

export const ALERT_DIALOG_CASES = [
'alert-over-a-toast',
'dialog-closed-after-save',
] as const;

export type AlertDialogCaseId = (typeof ALERT_DIALOG_CASES)[number];

export const ALERT_DIALOG_CASE_LABELS: Readonly<
Record<AlertDialogCaseId, string>
> = {
'alert-over-a-toast':
'An alert over a toast: Delete raises a toast as the alert closes',
'dialog-closed-after-save':
'A dialog closed after a save: Save raises a toast, and the dialog closes when the save is done',
};

export function parseAlertDialogCase(value: string | null): AlertDialogCaseId {
return (ALERT_DIALOG_CASES as readonly string[]).includes(value ?? '')
? (value as AlertDialogCaseId)
: ALERT_DIALOG_CASES[0];
}
119 changes: 119 additions & 0 deletions apps/sandbox/src/app/(raw)/pages/alert-dialog-cases/cases.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

/**
* @file cases.tsx
* @input A case id from caseIds.ts
* @output The case: an alert over a toast, or a dialog closed after a save
* that raised a toast
* @position The AlertDialog cases page's content. Each case is its Storybook
* story, on a sandbox page.
*/

import {useEffect, useRef, useState} from 'react';
import {AlertDialog} from '@astryxdesign/core/AlertDialog';
import {Button} from '@astryxdesign/core/Button';
import {Dialog} from '@astryxdesign/core/Dialog';
import {Stack} from '@astryxdesign/core/Stack';
import {Text} from '@astryxdesign/core/Text';
import {ToastViewport, useToast} from '@astryxdesign/core/Toast';
import type {ToastDismissFn} from '@astryxdesign/core/Toast';
import type {AlertDialogCaseId} from './caseIds';

function AlertOverAToast() {
const [isOpen, setIsOpen] = useState(false);
const [undoCount, setUndoCount] = useState(0);
const toast = useToast();
// The case's one toast. A new delete replaces it.
const dismissRef = useRef<ToastDismissFn | null>(null);
// Synchronizes the toast system with the case: leaving the case dismisses
// its toast.
useEffect(() => () => dismissRef.current?.(), []);
return (
<Stack gap={2}>
<Button
label="Delete item"
variant="destructive"
onClick={() => setIsOpen(true)}
/>
<Text>{`Undo taps: ${undoCount}`}</Text>
<AlertDialog
isOpen={isOpen}
onOpenChange={setIsOpen}
title="Delete item?"
description="This action cannot be undone. The item and all its data will be permanently removed."
actionLabel="Delete"
onAction={() => {
dismissRef.current = toast({
body: 'Item deleted.',
uniqueID: 'alert-over-a-toast',
isAutoHide: false,
endContent: (
<Button
label="Undo"
variant="secondary"
onClick={() => setUndoCount(count => count + 1)}
/>
),
});
setIsOpen(false);
}}
/>
</Stack>
);
}

/** Stands in for a request that the app waits for before it closes. */
async function saveItem(): Promise<void> {
await new Promise<void>(resolve => {
setTimeout(resolve, 300);
});
}

function SaveToastContent({onSaved}: {onSaved: () => void}) {
const toast = useToast();
const save = async () => {
toast({body: 'Saving the item.'});
await saveItem();
onSaved();
};
return (
<Stack gap={3}>
<Text>
Save shows a toast, then closes this dialog when the save is done.
</Text>
<Button
label="Save"
onClick={() => {
void save();
}}
/>
</Stack>
);
}

function DialogClosedAfterSave() {
const [isOpen, setIsOpen] = useState(false);
return (
<ToastViewport>
<Stack gap={2}>
<Button label="Open dialog" onClick={() => setIsOpen(true)} />
<Dialog
isOpen={isOpen}
onOpenChange={() => setIsOpen(false)}
aria-label="Edit item">
<SaveToastContent onSaved={() => setIsOpen(false)} />
</Dialog>
</Stack>
</ToastViewport>
);
}

export function AlertDialogCase({id}: {id: AlertDialogCaseId}) {
return id === 'alert-over-a-toast' ? (
<AlertOverAToast />
) : (
<DialogClosedAfterSave />
);
}
62 changes: 62 additions & 0 deletions apps/sandbox/src/app/(raw)/pages/alert-dialog-cases/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

/**
* @file page.tsx
* @input `?case=` (one of the ids in caseIds.ts; the first by default)
* @output A bare page with one AlertDialog case above rows that make the
* document scroll
* @position A raw page, with no sandbox chrome, for checking the cases on a
* phone. The page scrolls with the document, as an app's page does.
*/

import {Suspense} from 'react';
import {useSearchParams} from 'react-router-dom';
import {HStack, VStack} from '@astryxdesign/core/Layout';
import {Link} from '@astryxdesign/core/Link';
import {Heading, Text} from '@astryxdesign/core/Text';
import {AlertDialogCase} from './cases';
import {
ALERT_DIALOG_CASE_LABELS,
ALERT_DIALOG_CASES,
parseAlertDialogCase,
} from './caseIds';

const ROWS = Array.from({length: 40}, (_, index) => `Row ${index + 1}`);

function AlertDialogCases() {
const [searchParams] = useSearchParams();
const id = parseAlertDialogCase(searchParams.get('case'));
return (
<VStack gap={4} padding={4}>
<VStack gap={1}>
<Heading level={1}>AlertDialog cases</Heading>
<Text color="secondary">{ALERT_DIALOG_CASE_LABELS[id]}</Text>
<HStack gap={3}>
{ALERT_DIALOG_CASES.map(caseId => (
<Link key={caseId} href={`?case=${caseId}`}>
{caseId}
</Link>
))}
</HStack>
</VStack>
<AlertDialogCase key={id} id={id} />
<VStack gap={2}>
{ROWS.map(row => (
<Text key={row} color="secondary">
{row}
</Text>
))}
</VStack>
</VStack>
);
}

export default function AlertDialogCasesPage() {
return (
<Suspense>
<AlertDialogCases />
</Suspense>
);
}
6 changes: 6 additions & 0 deletions apps/sandbox/src/app/sandboxPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export const categories: SandboxCategory[] = [
description:
'A full page ChatLayout for phone checks. ?case= long (the default), composer or streaming scroll the document; docked scrolls a fixed-height panel',
},
{
name: 'AlertDialog Cases',
href: '/pages/alert-dialog-cases/',
description:
'An alert over a toast and a dialog closed after a save, on a page that scrolls with the document, to check on a phone',
},
{
name: 'TextArea Counter',
href: '/pages/textarea-counter/',
Expand Down
4 changes: 3 additions & 1 deletion apps/sandbox/src/hydration-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* @input Route and URL search string.
* @output Whether React can safely hydrate instead of client-rendering.
* @position Prevents mismatches for iframe themes and for pages whose first
* render reads URL controls (Shell Lab, Perf Scenes, Chat Layout).
* render reads URL controls (Shell Lab, Perf Scenes, Chat Layout,
* AlertDialog Cases).
*/

/** Pages whose first render reads the query string. */
const QUERY_RENDERED_PAGES = new Set([
'/pages/shell-lab/',
'/pages/perf-scenes/',
'/pages/chat-layout/',
'/pages/alert-dialog-cases/',
]);

export function canHydrate(route: string | undefined, search: string): boolean {
Expand Down
4 changes: 4 additions & 0 deletions apps/sandbox/src/route-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ describe('Sandbox static export contract', () => {
expect(canHydrate('/pages/chat-layout/', '')).toBe(true);
expect(canHydrate('/pages/perf-scenes/', '?scene=table')).toBe(false);
expect(canHydrate('/pages/perf-scenes/', '')).toBe(true);
expect(
canHydrate('/pages/alert-dialog-cases/', '?case=alert-over-a-toast'),
).toBe(false);
expect(canHydrate('/pages/alert-dialog-cases/', '')).toBe(true);
});

it('does not turn unknown URLs, dynamic segments or traversal into a 200 fallback', () => {
Expand Down
55 changes: 54 additions & 1 deletion apps/storybook/stories/AlertDialog.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

import {useState} from 'react';
import {useEffect, useRef, useState} from 'react';
import type {Meta, StoryObj} from '@storybook/react';
import {
AlertDialog,
useImperativeAlertDialog,
} from '@astryxdesign/core/AlertDialog';
import {Button} from '@astryxdesign/core/Button';
import {Stack} from '@astryxdesign/core/Stack';
import {Text} from '@astryxdesign/core/Text';
import {useToast} from '@astryxdesign/core/Toast';
import type {ToastDismissFn} from '@astryxdesign/core/Toast';

const meta: Meta<typeof AlertDialog> = {
title: 'Core/AlertDialog',
Expand Down Expand Up @@ -226,3 +230,52 @@ export const Inline: Story = {
onAction: () => {},
},
};

/**
* An action that raises a toast. Under a finger the alert fades out above the
* toast. The toast stays live meanwhile: its Undo button takes a tap during
* the fade, and assistive technology reads it.
*/
export const AlertOverAToast: Story = {
render: function AlertOverAToastStory() {
const [isOpen, setIsOpen] = useState(false);
const [undoCount, setUndoCount] = useState(0);
const toast = useToast();
// The story's one toast. A new delete replaces it, and leaving the story
// dismisses it.
const dismissRef = useRef<ToastDismissFn | null>(null);
useEffect(() => () => dismissRef.current?.(), []);
return (
<Stack gap={2}>
<Button
label="Delete item"
variant="destructive"
onClick={() => setIsOpen(true)}
/>
<Text>{`Undo taps: ${undoCount}`}</Text>
<AlertDialog
isOpen={isOpen}
onOpenChange={setIsOpen}
title="Delete item?"
description="This action cannot be undone. The item and all its data will be permanently removed."
actionLabel="Delete"
onAction={() => {
dismissRef.current = toast({
body: 'Item deleted.',
uniqueID: 'alert-over-a-toast',
isAutoHide: false,
endContent: (
<Button
label="Undo"
variant="secondary"
onClick={() => setUndoCount(count => count + 1)}
/>
),
});
setIsOpen(false);
}}
/>
</Stack>
);
},
};
18 changes: 12 additions & 6 deletions docs/architecture/layer-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ verified_by:
packages/core/src/Layer/useLayerDismissal.test.tsx,
packages/core/src/Layer/layerClickBoundary.test.tsx,
packages/core/src/Layer/layerDismissalInvariants.test.tsx,
packages/core/src/Layer/inputHold.test.tsx,
packages/core/src/Layer/layerExitCopy.test.ts,
packages/core/src/Layer/presentationHold.test.tsx,
packages/core/src/Layer/__tests__/layerExitCopy.interaction.browser.spec.ts,
Expand Down Expand Up @@ -461,7 +462,11 @@ do not slide out with it. A top-layer viewport renders into a host element
it owns, moves that host into the latest open outlet, returns it to the
viewport's tree position when no outlet is open, and enters the top layer again
after each move. Toasts therefore paint above the modal and stay operable inside
it. Moving the host does not remount the rows, so entries, timers, and focus
it. An input hold can make a layer's content inert, or the page's. A host
there stays live, as do the elements that hold it; their other children go
inert. The hold announces its shield's entry, so toasts stay operable above
the shield too.
Moving the host does not remount the rows, so entries, timers, and focus
handoff survive. The rule is one of order, not of modality, and it reaches
the surfaces that tell the registry they entered the top layer: the modal
outlets, and a non-modal top-layer surface that blocks nothing and announces
Expand Down Expand Up @@ -588,11 +593,12 @@ layers use Layer rendering without joining Escape/platform dismissal.
Otherwise a layer never paints at a geometry it is about to
correct, and the runtime polls nothing.
- **INV13 — One exit copy per closing layer.** A layer's close plays on at most
one exit copy, made by `placeLayerExitCopy`: drawn where the layer was drawn,
inert, hidden from assistive technology, without ids, form names, or form
owner, shown only in the top layer, and removed by its owner when the close
settles. Placing a second copy for the same layer removes the first; another
layer's copy stays.
one exit copy, made by `placeLayerExitCopy`, or taken by `takeLayerExitCopy`
and placed later: drawn where the layer was drawn, inert, hidden from
assistive technology, without ids, form names, or form owner, shown only in
the top layer, and removed by its owner when the close settles. Placing a
second copy for the same layer removes the first; another layer's copy
stays.
- **INV14 — The runtime owns every layer's shared mechanism.** Internally, the layer runtime owns the shared
mechanism layers use: top-layer mounting, close-request delivery, the
presentation hold (keeping a layer's chosen presentation from the open until
Expand Down
Loading