Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(core): a BottomSheet touch drag's close keeps its speed, and its scrim fades with it (#8105)

Christopher Chedeaub8ae86f94b3c
diff --git a/.changeset/bottom-sheet-drag-close.md b/.changeset/bottom-sheet-drag-close.md
new file mode 100644
index 0000000000..edcc189193
--- /dev/null
+++ b/.changeset/bottom-sheet-drag-close.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] BottomSheet: a sheet a touch drag closes leaves on its close spring, starting at the speed of the drag, and its scrim fades out with it on one clock, at the theme's tempo. A BottomSheetSwitcher flow's scrim does too. A mouse or pen drag is unchanged.
+
+@vjeux
diff --git a/.changeset/motion-settle-clock.md b/.changeset/motion-settle-clock.md
new file mode 100644
index 0000000000..d35f3fd614
--- /dev/null
+++ b/.changeset/motion-settle-clock.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[chore] Internal: the motion foundation's `resolveSettleMs` gives a spring role's settling time at the theme's tempo, so a CSS part that plays with the spring can start and land with it. Not exported from the package entry point.
+
+@vjeux
diff --git a/docs/specs/AST-094-touch-presentations/motion-roles.md b/docs/specs/AST-094-touch-presentations/motion-roles.md
index 0353725e08..656bc09318 100644
--- a/docs/specs/AST-094-touch-presentations/motion-roles.md
+++ b/docs/specs/AST-094-touch-presentations/motion-roles.md
@@ -21,6 +21,7 @@ The owner's goal: "The main goals are consistent timings and well-coordinated pi
| `springs.menuOpen` | spring | response 0.32 s, damping ratio 0.8 | `spec:AST-094` FR4 |
| `springs.quickChange` | spring | duration 0.5 s, bounce 0.15 | `spec:AST-094` FR4 |
| `springs.settle` | spring | duration 0.5 s, bounce 0 | `spec:AST-094` FR4 |
+| `springs.sheetDismissSwipe` | spring | response 0.3441442326 s, damping ratio 0.8 | `component:BottomSheet` |
| `springs.sliderDrop` | spring | response 0.5 s, damping ratio 0.7 | `component:Slider` |
| `springs.sliderLift` | spring | response 0.215 s, damping ratio 0.6 | `component:Slider` |
| `springs.sliderRelease` | spring | response 0.4 s, damping ratio 1 | `component:Slider` |
diff --git a/docs/specs/components/BottomSheet/BottomSheet.spec.md b/docs/specs/components/BottomSheet/BottomSheet.spec.md
index 282be0d0e2..e96edd1adb 100644
--- a/docs/specs/components/BottomSheet/BottomSheet.spec.md
+++ b/docs/specs/components/BottomSheet/BottomSheet.spec.md
@@ -169,7 +169,7 @@ remain documented in `BottomSheet.doc.mjs`.
| FR16 | An open modal sheet is a focus region through Core's shared focus-region module (`component:Dialog/DEC-2`): in the top sheet, Tab from the last tabbable control moves focus to the first and Shift+Tab from the first moves focus to the last, so focus never leaves the sheet for the browser's own interface. A covered or closing sheet does not answer Tab, and a non-modal sheet contains nothing (FR11). A switcher step (the deprecated BottomSheetSwitcher) is the exception to DEC-2, as `component:Dialog` DEC-2 states. | `component:Dialog/DEC-2` |
| FR17 | A BottomSheet open on the server, by its own `isOpen` or as a `BottomSheetSwitcher`'s active sheet, renders closed until hydration (no open styles, no `aria-modal`, the markup of a closed sheet) and opens in the render after hydration, the first that can enter its native host; it never claims a modality it does not have (`spec:AST-020` FR1, WCAG 2.2 SC 4.1.2). The server and hydrating renders produce the same markup (`spec:AST-013` FR9), and the open after hydration is settled, with no entry motion; later opens and closes animate as usual (`spec:AST-013` FR13). | `spec:AST-020` FR1 |
| FR18 | A finger's pull up past the tallest detent stretches the sheet on `spec:AST-094` FR3's rubber band, the same on every pull, with no hold. The sheet's surface reaches below the screen far enough for the whole stretch and the release, so the page under it never shows. A pull on the sheet's body stretches it as a pull on the grabber does, once the content has no room left to scroll that way: content that fits stretches at once, and a long list scrolls to its end first, then holds still while the sheet stretches. At every detent, a list that reaches its end mid-pull holds still while the sheet takes the rest of the pull. A sheet the caller sizes or styles keeps 48 px below the screen, and its stretch stops there. An inline block size, any `xstyle` and any class name count, because the sheet cannot read their rules. A mouse or a pen keeps its own resisted stretch, at most 48 px (`spec:AST-017` FR59). | DEC-3; `spec:AST-094` FR3 |
-| FR19 | A release settles on the detent nearest its projected position (`spec:AST-094` FR36); a release whose velocity points back toward its start returns to its starting detent (`spec:AST-094` FR37). An `info` sheet whose projection passes the dismiss point closes; a `form` or `required` sheet settles on its shortest detent (FR7). Implementation gap: the settle plays `--ease-standard` over the theme's `--duration-medium`, at a speed set by the distance left rather than the finger's (`spec:AST-094` FR38). Implementation gap: in WebKit, the settle stops advancing while the main thread is blocked (`spec:AST-094` FR5). Implementation gap: a release whose velocity points back toward its start still commits when it follows a net downward drag and its projection passes the dismiss point, or when its projection lies nearer the next detent in the drag's direction (`spec:AST-094` FR37). Implementation gap: a release after 48 px of travel or less projects nothing: it is judged where the finger lifted, so a short fast flick closes an `info` sheet only when the finger itself lifts past the dismiss point (`spec:AST-094` FR36). | `spec:AST-094` FR5, FR36, FR37, FR38; FR7 |
+| FR19 | A release settles on the detent nearest its projected position (`spec:AST-094` FR36); a release whose velocity points back toward its start returns to its starting detent (`spec:AST-094` FR37). An `info` sheet whose projection passes the dismiss point closes; a `form` or `required` sheet settles on its shortest detent (FR7). A sheet that a touch release closes leaves on its close spring from the release speed (`spec:AST-094` FR38), UIKit's measured swipe dismissal `springs.sheetDismissSwipe`, a motion role that the theme's `tempo` scales (`spec:AST-094` FR4, FR45). Its scrim fades for as long as that spring takes to settle at the theme's `tempo`, so the two finish together (`spec:AST-094` FR45's spring tiers; `spec:AST-108` FR4a). Under reduced motion its exit follows FR15. Implementation gap: the settle on a detent plays `--ease-standard` over the theme's `--duration-medium`, at a speed set by the distance left rather than the finger's (`spec:AST-094` FR38). Implementation gap: in WebKit, the settle stops advancing while the main thread is blocked (`spec:AST-094` FR5). Implementation gap: a release whose velocity points back toward its start still commits when it follows a net downward drag and its projection passes the dismiss point, or when its projection lies nearer the next detent in the drag's direction (`spec:AST-094` FR37). Implementation gap: a release after 48 px of travel or less projects nothing: it is judged where the finger lifted, so a short fast flick closes an `info` sheet only when the finger itself lifts past the dismiss point (`spec:AST-094` FR36). Implementation gap: a mouse or pen close plays the stylesheet's exit, not the close spring (`spec:AST-094` FR43, FR45). | `spec:AST-094` FR4, FR5, FR36, FR37, FR38, FR43, FR45; `spec:AST-108` FR4a; FR7 |
| FR20 | A standalone sheet (not a switcher step) removed while open is closed for focus: when it was the standalone or top sheet and focus was inside it, or fell to the body with its removal, focus returns as FR9 (modal) or FR11 (non-modal) state, to `finalFocusRef`, else the opener while it is still connected; with a sheet open beneath, focus goes into that revealed sheet by FR9. An FR10 replace keeps its handoff to the entering sheet, and a switcher step's change keeps FR12's handoff. Removing a whole stack in one update returns focus once, as FR9 closes it: to the bottom sheet's `finalFocusRef` or opener. Removing a covered sheet under a top sheet that stays moves no focus, because focus is in the top sheet. A removed opener moves no focus and raises no error. Implementation gap: a `BottomSheetSwitcher` flow removed while open, alone or as the bottom level of a stack, returns no focus. | `spec:AST-020/FR1` (WCAG 2.2 SC 2.4.3); FR9; FR11 |
### Allowed variation
@@ -396,7 +396,7 @@ a decision that they must remain unthemeable.
| FR16 | `BottomSheet.test.tsx` focus-region suite | Modal and non-modal sheets; Tab and Shift+Tab at the sheet's edge | Tab from the last control leaves a modal sheet, or a non-modal sheet captures Tab | `audit:BottomSheet/accessibility` |
| FR17 | `BottomSheet.ssr.test.tsx`; `BottomSheetSwitcher.test.tsx` flow that mounts open | Open on the server; hydration; a closed sheet's markup | An open server render with `aria-modal`, open styles, or markup unlike a closed one, a hydration error, no `showModal()` after hydration, an entry motion on the open right after hydration, or none on a later open fails. | `audit:BottomSheet/accessibility` |
| FR18 | `useSheetGestures.test.ts` stretch suites; `BottomSheetPanel.test.tsx` reserve cases; `BottomSheetDrag.a11y.chromium.spec.ts` | Three finger pulls past the top; short content pulled up on its body at five points, the first pull and every one after it; a long list pulled past its end; a mouse pull and a pen pull | A capped or held stretch, a pull that stretches less than the one before it, a body pull on short content that moves nothing, a long list that never stretches the sheet once at its end or rubber-bands itself while the sheet stretches, or a reserve under 40% of the viewport on a device with a touch pointer fails, unless the caller sizes or styles the sheet (48 px). | `audit:BottomSheet/behavior` |
-| FR19 | `BottomSheetDetent.interaction.browser.spec.ts`; `useSheetGestures.test.ts`; `snapOffsets.test.ts` | On the Snap points story under real touch input: a slow release between detents, a 2,000 px/s downward flick, the settle to a detent with its curve recorded (FR19's FR38 gap), in Chromium the settle through a 700 ms main-thread block (`spec:AST-094` FR5; WebKit's gap is skipped), and a rendering trace of the settle in Chromium | A slow release that lands off the nearest detent, a flick past the dismiss point that leaves the sheet open, a settle that ends off the detent, or a settle that stalls while the main thread is blocked, or lays out or paints during the settle, fails | `audit:BottomSheet/behavior` |
+| FR19 | `BottomSheetDetent.interaction.browser.spec.ts`; `BottomSheetRelease.a11y.chromium.spec.ts`; `useSheetGestures.test.ts`; `BottomSheetDragExit.test.tsx`; `snapOffsets.test.ts` | On the Snap points story under real touch input: a slow release between detents, a 2,000 px/s downward flick, the settle to a detent with its curve recorded (FR19's FR38 gap), in Chromium the settle through a 700 ms main-thread block (`spec:AST-094` FR5; WebKit's gap is skipped), and a rendering trace of the settle in Chromium. Touch: a drag's close, a reopen during it, its scrim at tempo 0.75, 1 and 1.5. Mouse: a close; one under reduced motion. A close from a control | A slow release that lands off the nearest detent, a flick past the dismiss point that leaves the sheet open, a touch exit that starts from rest, a scrim that fades longer or shorter than the close spring settles, a mouse drag that plays the close spring, a reduced-motion mouse close that moves, a settle that ends off the detent, or a settle that stalls while the main thread is blocked, or lays out or paints during the settle, fails | `audit:BottomSheet/behavior` |
| FR20 | `BottomSheetCloseFocus.test.tsx` "BottomSheet removed while open" suite; real-browser focus check in Chromium | A modal and a non-modal sheet removed from inside; `finalFocusRef`; the top sheet of a stack removed; a covered sheet removed under a top sheet that stays; a whole stack removed in one update; a sheet removed in the update that opens another; an opener removed with the sheet | Focus on `body` after a removal from inside, focus on `body` after a whole stack is removed, focus moved out of the top sheet when a covered sheet is removed, focus pulled out of a sheet that opened in the same update, or an error when the opener is gone, fails. | `audit:BottomSheet/behavior` |
Existing tests directly assert the Sheet panel target, Content area placement,
diff --git a/packages/core/src/BottomSheet/BottomSheet.tsx b/packages/core/src/BottomSheet/BottomSheet.tsx
index 57a801bc2e..17e6a5548c 100644
--- a/packages/core/src/BottomSheet/BottomSheet.tsx
+++ b/packages/core/src/BottomSheet/BottomSheet.tsx
@@ -305,6 +305,37 @@ function scrimOpacityForView(view: BottomSheetStackView): '0' | '1' {
return view.isStacked && !view.ownsScrim ? '0' : '1';
}
+/**
+ * Writes the fade a touch drag's close paces on `dialog`'s scrim, or clears
+ * it when `ms` is null. `written` keeps the value the host wrote, so a clear
+ * removes only that value.
+ */
+function writeScrimFadeDuration(
+ dialog: HTMLDialogElement | null,
+ ms: number | null,
+ written: {current: string | null},
+): void {
+ if (dialog == null) {
+ return;
+ }
+ const current = dialog.style.getPropertyValue('--_sheet-scrim-duration');
+ if (ms == null) {
+ // Remove only the value this host wrote. A stack's 0s pin written since
+ // then stays.
+ if (written.current != null && current === written.current) {
+ dialog.style.removeProperty('--_sheet-scrim-duration');
+ }
+ written.current = null;
+ return;
+ }
+ // A stack's 0s pin hands the scrim over with no fade; it stays.
+ if (current === '0s') {
+ return;
+ }
+ written.current = `${ms}ms`;
+ dialog.style.setProperty('--_sheet-scrim-duration', written.current);
+}
+
interface BottomSheetSharedProps extends BaseProps<HTMLDivElement> {
/** Ref forwarded to the visual sheet panel <div>. */
ref?: React.Ref<HTMLDivElement>;
@@ -544,6 +575,18 @@ function StandaloneBottomSheet({
String(opacity),
);
}, []);
+ // The fade duration a touch drag's close wrote, until that close ends.
+ const scrimFadeRef = useRef<string | null>(null);
+ const handleScrimFadeDuration = useCallback(
+ (panel: HTMLElement, ms: number | null) => {
+ const view = stackViewRef.current;
+ if (view.isStacked && !view.ownsScrim) {
+ return;
+ }
+ writeScrimFadeDuration(panel.closest('dialog'), ms, scrimFadeRef);
+ },
+ [],
+ );
// A sheet joins the registry for as long as it is presented. For a modal
// sheet the registry shows the dialog (in open order, repairing same-commit
@@ -946,6 +989,7 @@ function StandaloneBottomSheet({
xstyle={xstyle}
onDismiss={dismissOnLightInteraction}
onScrimOpacity={handleScrimOpacity}
+ onScrimFadeDuration={handleScrimFadeDuration}
onElementChange={handlePanelElementChange}
onMotionStart={handleMotionStart}
onMotionComplete={handleMotionComplete}>
@@ -1095,6 +1139,16 @@ function SwitcherBottomSheetItem({
},
[hasValidSheetId, onSheetScrimOpacityChange, sheetId],
);
+ // The fade a touch drag's close wrote on this step's dialog, until that
+ // close ends. The step a drag closes becomes the flow's retained step, so
+ // its backdrop is the flow's scrim.
+ const scrimFadeRef = useRef<string | null>(null);
+ const handleScrimFadeDuration = useCallback(
+ (panel: HTMLElement, ms: number | null) => {
+ writeScrimFadeDuration(panel.closest('dialog'), ms, scrimFadeRef);
+ },
+ [],
+ );
useLayoutEffect(() => {
if (!hasValidSheetId) {
@@ -1297,6 +1351,7 @@ function SwitcherBottomSheetItem({
xstyle={xstyle}
onDismiss={dismissOnSwipe}
onScrimOpacity={handleScrimOpacity}
+ onScrimFadeDuration={handleScrimFadeDuration}
onElementChange={handlePanelElementChange}
onMotionStart={handleMotionStart}
onMotionComplete={handleMotionComplete}>
diff --git a/packages/core/src/BottomSheet/BottomSheetDragExit.test.tsx b/packages/core/src/BottomSheet/BottomSheetDragExit.test.tsx
new file mode 100644
index 0000000000..ed9500653e
--- /dev/null
+++ b/packages/core/src/BottomSheet/BottomSheetDragExit.test.tsx
@@ -0,0 +1,351 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file BottomSheetDragExit.test.tsx
+ * @input BottomSheet, with the shared animator replaced by a recorder
+ * @output Unit tests for the exit a drag's close plays. It starts the close
+ * spring from where the finger left the sheet, and a reopen takes it back.
+ * The scrim fades for as long as that close plays, decided before the
+ * scrim starts to clear. That holds on a standalone sheet and on a
+ * switcher flow
+ * @position The jsdom side of the drag exit; the Chromium release spec reads
+ * the curve the browser plays.
+ */
+
+import {act, fireEvent, render, screen} from '@testing-library/react';
+import {useState} from 'react';
+import {afterEach, beforeEach, expect, it, vi} from 'vitest';
+import {SETTLE_THRESHOLD} from '../motion/animator';
+import type * as AnimatorModule from '../motion/animator';
+import {solveSpring, toSpring} from '../motion/spring';
+import {springs} from '../motion/uikit/springs';
+import {BottomSheet} from './BottomSheet';
+import {BottomSheetSwitcher} from './BottomSheetSwitcher';
+import {resetBottomSheetStackForTests} from './bottomSheetStack';
+
+interface RecordedExit {
+ values: Record<string, number>;
+ options: {velocity?: Record<string, number>};
+ finish: () => void;
+ retarget: ReturnType<typeof vi.fn>;
+}
+
+const exits: RecordedExit[] = [];
+
+// The sheet's open height reaches it through a resize observer. A touch
+// release lands by that geometry, so each test lays the sheet out.
+const observers: {callback: ResizeObserverCallback; observed: Set<Element>}[] =
+ [];
+class ResizeObserverMock {
+ callback: ResizeObserverCallback;
+ observed = new Set<Element>();
+ constructor(callback: ResizeObserverCallback) {
+ this.callback = callback;
+ observers.push(this);
+ }
+ observe(target: Element) {
+ this.observed.add(target);
+ }
+ unobserve(target: Element) {
+ this.observed.delete(target);
+ }
+ disconnect() {
+ this.observed.clear();
+ }
+}
+
+/** Lays the sheet out 400 px tall, as the browser's resize observer would. */
+function layOutSheet(label = 'Sheet') {
+ const sheet = document.querySelector<HTMLElement>(
+ `dialog[aria-label="${label}"] .astryx-bottom-sheet`,
+ );
+ const observer = observers.find(
+ instance => sheet != null && instance.observed.has(sheet),
+ );
+ const entry: Partial<ResizeObserverEntry> = {
+ borderBoxSize: [{blockSize: 400, inlineSize: 100}],
+ contentRect: {height: 400} as DOMRectReadOnly,
+ };
+ act(() => {
+ observer?.callback(
+ [entry as ResizeObserverEntry],
+ observer as unknown as ResizeObserver,
+ );
+ });
+}
+
+vi.mock('../motion/animator', async importOriginal => {
+ const actual = await importOriginal<typeof AnimatorModule>();
+ return {
+ ...actual,
+ animatorFor: () => ({
+ animate: (
+ values: Record<string, number>,
+ options: RecordedExit['options'],
+ ) => {
+ let finish = () => {};
+ const finished = new Promise<boolean>(resolve => {
+ finish = () => resolve(true);
+ });
+ const exit = {
+ values,
+ options,
+ finish,
+ retarget: vi.fn(),
+ finished,
+ started: Promise.resolve(0),
+ };
+ exits.push(exit);
+ return exit;
+ },
+ set: vi.fn(),
+ }),
+ };
+});
+
+beforeEach(() => {
+ exits.length = 0;
+ observers.length = 0;
+ vi.stubGlobal('ResizeObserver', ResizeObserverMock);
+ resetBottomSheetStackForTests();
+ HTMLDialogElement.prototype.showModal = vi.fn(function (
+ this: HTMLDialogElement,
+ ) {
+ this.setAttribute('open', '');
+ });
+ HTMLDialogElement.prototype.close = vi.fn(function (this: HTMLDialogElement) {
+ this.removeAttribute('open');
+ });
+ if (!Element.prototype.setPointerCapture) {
+ Element.prototype.setPointerCapture = vi.fn();
+ Element.prototype.releasePointerCapture = vi.fn();
+ }
+ // The exit plays only where Web Animations exist.
+ Element.prototype.animate = vi.fn();
+ window.scrollTo = vi.fn();
+ vi.stubGlobal(
+ 'matchMedia',
+ vi.fn().mockReturnValue({
+ matches: false,
+ media: '',
+ onchange: null,
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ }),
+ );
+ vi.stubGlobal(
+ 'requestAnimationFrame',
+ vi.fn((callback: FrameRequestCallback) => {
+ callback(0);
+ return 1;
+ }),
+ );
+ vi.stubGlobal('cancelAnimationFrame', vi.fn());
+});
+
+afterEach(() => {
+ Reflect.deleteProperty(Element.prototype, 'animate');
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+});
+
+function Host() {
+ const [isOpen, setIsOpen] = useState(true);
+ return (
+ <>
+ <button type="button" onClick={() => setIsOpen(true)}>
+ Reopen
+ </button>
+ <BottomSheet isOpen={isOpen} onOpenChange={setIsOpen} label="Sheet">
+ Content
+ </BottomSheet>
+ </>
+ );
+}
+
+function getHandle(label = 'Sheet'): HTMLElement {
+ const handle = document
+ .querySelector(`dialog[aria-label="${label}"] .astryx-bottom-sheet`)
+ ?.querySelector<HTMLElement>('[aria-hidden="true"]');
+ if (handle == null) {
+ throw new Error('grab handle not found');
+ }
+ return handle;
+}
+
+/** A fast downward touch drag on the handle: a flick, which closes the sheet. */
+function flickDown(label = 'Sheet') {
+ const handle = getHandle(label);
+ fireEvent.pointerDown(handle, {
+ pointerId: 1,
+ pointerType: 'touch',
+ clientY: 0,
+ button: 0,
+ isPrimary: true,
+ });
+ fireEvent.pointerMove(handle, {pointerId: 1, clientY: 40});
+ fireEvent.pointerMove(handle, {pointerId: 1, clientY: 120});
+ fireEvent.pointerUp(handle, {pointerId: 1, clientY: 120});
+}
+
+it('plays the close spring when a drag closes the sheet', () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ expect(exits).toHaveLength(1);
+ expect(exits[0].values.y).toBeGreaterThan(0);
+});
+
+it('takes the sheet back to rest when it reopens during a drag exit', () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ expect(exits).toHaveLength(1);
+ act(() => {
+ fireEvent.click(screen.getByRole('button', {name: 'Reopen'}));
+ });
+ expect(exits[0].retarget).toHaveBeenCalledWith({y: 0});
+});
+
+it('leaves a finished exit where it ended', async () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ await act(async () => {
+ exits[0].finish();
+ });
+ expect(exits[0].retarget).not.toHaveBeenCalled();
+});
+
+/** The inline fade duration on the sheet's dialog, '' when none. */
+function scrimFade(label = 'Sheet'): string {
+ const dialog = document.querySelector<HTMLDialogElement>(
+ `dialog[aria-label="${label}"]`,
+ );
+ return dialog?.style.getPropertyValue('--_sheet-scrim-duration') ?? '';
+}
+
+it('fades the scrim for as long as the close plays when a drag closes the sheet', () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ const [exit] = exits;
+ // The move the animator was handed, timed as the animator times it. No
+ // theme sets a tempo here.
+ const close = solveSpring(toSpring(springs.sheetDismissSwipe), {
+ from: 0,
+ to: exit.values.y,
+ velocity: exit.options.velocity?.y,
+ });
+ expect(scrimFade()).toBe(`${close.settleTime(SETTLE_THRESHOLD.y) * 1000}ms`);
+});
+
+/** Records each inline style property write, as `name: value`. */
+function recordStyleWrites(): string[] {
+ const writes: string[] = [];
+ const setProperty = CSSStyleDeclaration.prototype.setProperty;
+ vi.spyOn(CSSStyleDeclaration.prototype, 'setProperty').mockImplementation(
+ function (
+ this: CSSStyleDeclaration,
+ name: string,
+ value: string | null,
+ priority?: string,
+ ) {
+ writes.push(`${name}: ${value}`);
+ setProperty.call(this, name, value, priority);
+ },
+ );
+ return writes;
+}
+
+/** Expects the scrim's fade to be written before the scrim starts to clear. */
+function expectFadeBeforeClear(writes: string[]) {
+ // A fade written after the clear would not reach the running transition.
+ const fade = writes.findIndex(write =>
+ write.startsWith('--_sheet-scrim-duration: '),
+ );
+ const clear = writes.indexOf('--_sheet-scrim-opacity: 0');
+ expect(fade).toBeGreaterThanOrEqual(0);
+ expect(clear).toBeGreaterThan(fade);
+}
+
+it("decides the scrim's fade before the scrim starts to clear", () => {
+ const writes = recordStyleWrites();
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ expectFadeBeforeClear(writes);
+});
+
+function Flow() {
+ const [activeSheet, setActiveSheet] = useState<string | null>('steps');
+ return (
+ <BottomSheetSwitcher
+ activeSheet={activeSheet}
+ onActiveSheetChange={setActiveSheet}>
+ <BottomSheet sheetId="steps" label="Steps">
+ Content
+ </BottomSheet>
+ </BottomSheetSwitcher>
+ );
+}
+
+it("fades a switcher flow's scrim for as long as the close plays when a drag closes it", () => {
+ const writes = recordStyleWrites();
+ render(<Flow />);
+ layOutSheet('Steps');
+ flickDown('Steps');
+ expect(exits).toHaveLength(1);
+ const [exit] = exits;
+ const close = solveSpring(toSpring(springs.sheetDismissSwipe), {
+ from: 0,
+ to: exit.values.y,
+ velocity: exit.options.velocity?.y,
+ });
+ expect(scrimFade('Steps')).toBe(
+ `${close.settleTime(SETTLE_THRESHOLD.y) * 1000}ms`,
+ );
+ expectFadeBeforeClear(writes);
+});
+
+it("clears the scrim's fade duration when the drag exit ends", async () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ expect(scrimFade()).not.toBe('');
+ await act(async () => {
+ exits[0].finish();
+ });
+ expect(scrimFade()).toBe('');
+});
+
+it("clears the scrim's fade duration when the sheet reopens during a drag exit", () => {
+ render(<Host />);
+ layOutSheet();
+ flickDown();
+ act(() => {
+ fireEvent.click(screen.getByRole('button', {name: 'Reopen'}));
+ });
+ expect(scrimFade()).toBe('');
+});
+
+it("leaves the scrim's fade alone when a mouse drag closes the sheet", () => {
+ render(<Host />);
+ layOutSheet();
+ const handle = getHandle();
+ fireEvent.pointerDown(handle, {
+ pointerId: 2,
+ pointerType: 'mouse',
+ clientY: 0,
+ button: 0,
+ isPrimary: true,
+ });
+ fireEvent.pointerMove(handle, {pointerId: 2, clientY: 200});
+ fireEvent.pointerMove(handle, {pointerId: 2, clientY: 390});
+ fireEvent.pointerUp(handle, {pointerId: 2, clientY: 390});
+ expect(exits).toHaveLength(0);
+ expect(scrimFade()).toBe('');
+});
diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
index 653eba94aa..73795e6545 100644
--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx
+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
@@ -68,11 +68,15 @@ import {
resolveSnapPoints,
type BottomSheetSnapPoint,
} from './snapOffsets';
+import {animatorFor, SETTLE_THRESHOLD} from '../motion/animator';
+import {resolveSettleMs} from '../motion/resolveMotion';
+import {springs} from '../motion/uikit/springs';
import {useMobileKeyboard} from '../keyboard/useMobileKeyboard';
import {
scrollPreservationPadding,
sheetLayoutHeight,
useSheetGestures,
+ type SheetDragExit,
} from './useSheetGestures';
const HEIGHT_BUDGETS = {
@@ -99,6 +103,8 @@ function sheetReserve(viewportHeight: number): number {
);
}
const MOBILE_KEYBOARD_BOTTOM_CLEARANCE = 48;
+// How many more frames a drag's close looks for its scrim's fade to adopt.
+const MAX_SCRIM_FADE_ADOPT_FRAMES = 3;
const TRANSITION_BACKSTOP_BUFFER_MS = 50;
// The floating handle bar's height. The bar is out of flow, so this is not
// layout space the content pays for -- the pill (4px, centered) lands 10-14px
@@ -122,6 +128,54 @@ function hasStyles(xstyle: unknown): boolean {
: xstyle != null && typeof xstyle === 'object';
}
+function supportsWebAnimations(): boolean {
+ return (
+ typeof Element !== 'undefined' &&
+ typeof Element.prototype.animate === 'function'
+ );
+}
+
+/**
+ * How long a drag's close plays, in ms. It is the close spring's move from
+ * where the finger left the sheet, timed as the shared animator times it.
+ */
+function dragExitMs(element: Element, exit: SheetDragExit): number {
+ return resolveSettleMs(element, springs.sheetDismissSwipe, {
+ from: 0,
+ to: exit.distance,
+ velocity: exit.velocity,
+ epsilon: SETTLE_THRESHOLD.y,
+ });
+}
+
+/** The running fade that clears the scrim behind `panel`, if any. */
+function clearingScrimFade(panel: Element): Animation | undefined {
+ const dialog = panel.closest('dialog');
+ const doc = panel.ownerDocument;
+ if (dialog == null || typeof doc.getAnimations !== 'function') {
+ return undefined;
+ }
+ const fades = doc.getAnimations().filter(animation => {
+ const effect = animation.effect as KeyframeEffect | null;
+ return (
+ effect?.target === dialog &&
+ (animation as CSSTransition).transitionProperty === 'opacity' &&
+ // Skip a fade that the drag started. A style update replaces that fade.
+ Number(effect.getKeyframes().at(-1)?.opacity) === 0
+ );
+ });
+ const onBackdrop = fades.filter(
+ fade => (fade.effect as KeyframeEffect).pseudoElement === '::backdrop',
+ );
+ // An engine that reports no backdrop effect (WebKit) puts the backdrop's
+ // fade on the dialog itself, which runs no opacity transition of its own.
+ return (
+ onBackdrop.length > 0
+ ? onBackdrop
+ : fades.filter(fade => !(fade.effect as KeyframeEffect).pseudoElement)
+ ).at(-1);
+}
+
// Measure the viewport that the height budgets use. They are `dvh`, which
// the virtual keyboard does not shrink, so `visualViewport` would differ by
// the keyboard's height. `useMobileKeyboard` handles the keyboard and does
@@ -435,6 +489,13 @@ interface BottomSheetPanelProps extends BaseProps<HTMLDivElement> {
isPageScrollLocked?: boolean;
onDismiss: () => void;
onScrimOpacity: (opacity: number) => void;
+ /**
+ * The scrim's fade under a touch drag's close, in milliseconds, or null
+ * once that close ends or a reopen takes the sheet back. `panel` is the
+ * sheet's element: the commit that starts the close can detach the host's
+ * dialog ref while this runs.
+ */
+ onScrimFadeDuration?: (panel: HTMLElement, ms: number | null) => void;
onElementChange?: (element: HTMLDivElement | null) => void;
onMotionStart?: (motion: BottomSheetPanelMotion) => void;
onMotionComplete?: (motion: BottomSheetPanelMotion) => void;
@@ -612,6 +673,7 @@ export function BottomSheetPanel({
isPageScrollLocked = false,
onDismiss,
onScrimOpacity,
+ onScrimFadeDuration,
onElementChange,
onMotionStart,
onMotionComplete,
@@ -625,6 +687,7 @@ export function BottomSheetPanel({
const reactivatedEntranceRef = useRef(false);
const onMotionStartRef = useRef(onMotionStart);
const onMotionCompleteRef = useRef(onMotionComplete);
+ const onScrimFadeDurationRef = useRef(onScrimFadeDuration);
const startedMotionRef = useRef<BottomSheetPanelMotion | null>(null);
const pendingMotionCompleteRef = useRef<BottomSheetPanelMotion | null>(null);
@@ -641,7 +704,8 @@ export function BottomSheetPanel({
previousStateRef.current = state;
onMotionStartRef.current = onMotionStart;
onMotionCompleteRef.current = onMotionComplete;
- }, [onMotionComplete, onMotionStart, state]);
+ onScrimFadeDurationRef.current = onScrimFadeDuration;
+ }, [onMotionComplete, onMotionStart, onScrimFadeDuration, state]);
const isInteractive = state.kind === 'open';
const isPresented = state.kind !== 'hidden';
@@ -715,6 +779,7 @@ export function BottomSheetPanel({
settledOffset,
isDragging,
isDismissedByTouchDrag,
+ dragExit,
sheetHeight,
scrollPreservationInset,
settlingLayoutOffset,
@@ -757,12 +822,20 @@ export function BottomSheetPanel({
},
[onElementChange, sheetRef],
);
+ // The element a drag's exit moved, until the sheet is hidden.
+ const dragExitElementRef = useRef<HTMLElement | null>(null);
useLayoutEffect(() => {
if (isPresentedRef.current === isPresented) {
return;
}
isPresentedRef.current = isPresented;
sheetRef(isPresented ? elementRef.current : null);
+ // A hidden sheet can stay mounted, so the exit's offset goes back to 0.
+ const exited = dragExitElementRef.current;
+ if (!isPresented && exited != null) {
+ dragExitElementRef.current = null;
+ animatorFor(exited).set({y: 0});
+ }
}, [isPresented, sheetRef]);
const keyboard = useMobileKeyboard(elementRef, {
move: 'ride',
@@ -790,8 +863,33 @@ export function BottomSheetPanel({
const isCoarseCrossFade = useMediaQuery(REDUCED_MOTION_COARSE_QUERY);
const isCrossFade =
isCoarseCrossFade || (isReducedMotion && isDismissedByTouchDrag);
- // Syncs the motion with the panel's CSS transition. The motion completes when
- // that transition ends.
+ // Without Web Animations the animator jumps the sheet to its end, so the
+ // stylesheet's exit runs.
+ const playedDragExit =
+ dragExit != null &&
+ !isCrossFade &&
+ !isReducedMotion &&
+ supportsWebAnimations()
+ ? dragExit
+ : null;
+ // Syncs the scrim's fade with a drag's close. It runs as the host takes the
+ // close, before the host clears the scrim, so the fade starts on the
+ // close's own clock.
+ useLayoutEffect(() => {
+ const element = elementRef.current;
+ if (playedDragExit == null || element == null) {
+ return;
+ }
+ onScrimFadeDurationRef.current?.(
+ element,
+ dragExitMs(element, playedDragExit),
+ );
+ return () => {
+ onScrimFadeDurationRef.current?.(element, null);
+ };
+ }, [playedDragExit]);
+ // Syncs the motion with the panel's CSS transition, or a drag's exit with
+ // the shared animator. The motion completes when that one ends.
useLayoutEffect(() => {
if (motion == null) {
return;
@@ -815,6 +913,55 @@ export function BottomSheetPanel({
complete();
return;
}
+ const element = elementRef.current;
+ if (motion === 'exiting' && playedDragExit != null && element != null) {
+ dragExitElementRef.current = element;
+ const exit = animatorFor(element).animate(
+ {y: playedDragExit.distance},
+ {
+ spring: springs.sheetDismissSwipe,
+ velocity: {y: playedDragExit.velocity},
+ },
+ );
+ let isCurrent = true;
+ let isFinished = false;
+ let frame: number | null = null;
+ // The scrim's fade follows the close. Once the close starts, the fade
+ // takes its start time, so the two end together. If the fade has no
+ // style yet, look for it again on each of the next few frames.
+ void exit.started.then(start => {
+ const adopt = (framesLeft: number) => {
+ frame = null;
+ if (!isCurrent) {
+ return;
+ }
+ const fade = clearingScrimFade(element);
+ if (fade != null) {
+ fade.startTime = start;
+ } else if (framesLeft > 0) {
+ frame = requestAnimationFrame(() => adopt(framesLeft - 1));
+ }
+ };
+ adopt(MAX_SCRIM_FADE_ADOPT_FRAMES);
+ });
+ void exit.finished.then(() => {
+ isFinished = true;
+ onScrimFadeDurationRef.current?.(element, null);
+ if (isCurrent) {
+ complete();
+ }
+ });
+ return () => {
+ isCurrent = false;
+ if (frame != null) {
+ cancelAnimationFrame(frame);
+ }
+ // A reopen during the exit takes the sheet back from where it is.
+ if (!isFinished) {
+ exit.retarget({y: 0});
+ }
+ };
+ }
// What ends a motion: the fade is opacity, and the entrance, alignment and
// exit are transforms. Under the reduced-motion cross-fade an exit fades
// where it is, and its dialog closes only after the fade, so it waits on
@@ -826,7 +973,7 @@ export function BottomSheetPanel({
motion === 'fading' || crossFadeMotion ? 'opacity' : 'transform',
complete,
);
- }, [motion, isCrossFade]);
+ }, [motion, isCrossFade, playedDragExit]);
// The snap is transform-only; the layout height reconciles when it lands.
// waitForTransition — the same helper the motion states use — resolves that
// even when no `transitionend` is coming: inline or computed
@@ -940,7 +1087,12 @@ export function BottomSheetPanel({
}
const element = elementRef.current;
if (element != null) {
- if (consumerTransform == null) {
+ // A drag's close holds the sheet where the finger left it, so the exit
+ // starts from there. A step back to rest first would turn the sheet
+ // the wrong way.
+ const holdsDragClose =
+ dragExit != null && (!isClosing || playedDragExit != null);
+ if (consumerTransform == null && !holdsDragClose) {
element.style.transform = sheetTransform ?? '';
}
if (consumerHeight == null) {
diff --git a/packages/core/src/BottomSheet/__tests__/BottomSheetRelease.a11y.chromium.spec.ts b/packages/core/src/BottomSheet/__tests__/BottomSheetRelease.a11y.chromium.spec.ts
new file mode 100644
index 0000000000..1e61a8a203
--- /dev/null
+++ b/packages/core/src/BottomSheet/__tests__/BottomSheetRelease.a11y.chromium.spec.ts
@@ -0,0 +1,364 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+// @pr-a11y release-only
+
+/**
+ * @file BottomSheetRelease.a11y.chromium.spec.ts
+ * @input Built BottomSheet stories and real Chromium touch input (CDP), each
+ * event with its own timestamp
+ * @output Browser evidence for a touch drag's close: the close and its
+ * scrim's running fade play on one clock and end together. That holds at
+ * each tempo, from the top snap point, and in a switcher flow. A mouse
+ * close under reduced motion moves no further.
+ * @position Chromium proof for the drag's close and its scrim. The page reads
+ * the events' timestamps, so load cannot change the release speed.
+ */
+
+import {
+ expect,
+ test,
+ type CDPSession,
+ type Locator,
+ type Page,
+} from '@astryxdesign/a11y-spec/playwright';
+import {
+ DEFAULT_STORYBOOK_DIR,
+ serveStorybook,
+ type StaticServer,
+} from '@astryxdesign/a11y-spec/storybook';
+import {END_HOLD_MS} from '../../motion/animator';
+
+let storybook: StaticServer;
+test.beforeAll(async () => {
+ storybook = await serveStorybook(
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
+ );
+});
+test.afterAll(async () => {
+ await storybook?.close();
+});
+
+test.use({hasTouch: true, viewport: {width: 390, height: 844}});
+
+async function openFilters(page: Page) {
+ return openSheet(page, 'showcase', 'Open sheet', 'Filters');
+}
+
+async function openSheet(
+ page: Page,
+ story: string,
+ opener: string | null,
+ name: string,
+ component = 'bottomsheet',
+) {
+ await page.goto(
+ `${storybook.origin}/iframe.html?id=core-${component}--${story}&viewMode=story`,
+ );
+ if (opener != null) {
+ await page.getByRole('button', {name: opener}).click();
+ }
+ const dialog = page.getByRole('dialog', {name});
+ await expect(dialog).toBeVisible();
+ const sheet = dialog.locator('.astryx-bottom-sheet').first();
+ // At rest: nothing runs, and the sheet holds still between two frames.
+ await expect
+ .poll(async () =>
+ page.evaluate(async () => {
+ const running = document
+ .getAnimations()
+ .some(animation => animation.playState === 'running');
+ const top = () =>
+ document
+ .querySelector('.astryx-bottom-sheet')
+ ?.getBoundingClientRect().top ?? 0;
+ const before = top();
+ await new Promise(resolve => requestAnimationFrame(resolve));
+ return !running && Math.abs(top() - before) < 0.5;
+ }),
+ )
+ .toBe(true);
+ return {dialog, sheet};
+}
+
+/** A drag on the grabber of `distance` px in `ms`, each event timestamped. */
+async function drag(
+ cdp: CDPSession,
+ sheet: Locator,
+ distance: number,
+ ms: number,
+) {
+ const box = await sheet.boundingBox();
+ if (box == null) {
+ throw new Error('no sheet box');
+ }
+ const x = box.x + box.width / 2;
+ const y = box.y + 12;
+ const base = Date.now();
+ const steps = 6;
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchStart',
+ touchPoints: [{x, y}],
+ timestamp: base / 1000,
+ });
+ for (let i = 1; i <= steps; i += 1) {
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchMove',
+ touchPoints: [{x, y: y + (distance * i) / steps}],
+ timestamp: (base + (ms * i) / steps) / 1000,
+ });
+ }
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchEnd',
+ touchPoints: [],
+ timestamp: (base + ms + 1) / 1000,
+ });
+}
+
+test('a mouse close under reduced motion moves the sheet no further', async ({
+ page,
+}) => {
+ await page.emulateMedia({reducedMotion: 'reduce'});
+ const {dialog, sheet} = await openFilters(page);
+ const rest = await sheet.evaluate(el => el.getBoundingClientRect());
+ // Every frame's sheet top, and the time the button comes up.
+ await page.evaluate(() => {
+ const frames = {
+ samples: [] as [number, number][],
+ upAt: Number.POSITIVE_INFINITY,
+ done: false,
+ };
+ (window as unknown as {sheetFrames: typeof frames}).sheetFrames = frames;
+ window.addEventListener(
+ 'pointerup',
+ () => {
+ frames.upAt = performance.now();
+ },
+ {capture: true},
+ );
+ const record = (now: number) => {
+ const panel = document.querySelector('.astryx-bottom-sheet');
+ if (panel == null || document.querySelector('dialog[open]') == null) {
+ frames.done = true;
+ return;
+ }
+ frames.samples.push([now, panel.getBoundingClientRect().top]);
+ requestAnimationFrame(record);
+ };
+ requestAnimationFrame(record);
+ });
+ const x = rest.x + rest.width / 2;
+ const y = rest.y + 12;
+ await page.mouse.move(x, y);
+ await page.mouse.down();
+ await page.mouse.move(x, y + 150, {steps: 5});
+ await page.mouse.up();
+ // While the dialog closes, no drag exit plays: no inline transition and no
+ // animation moves the sheet.
+ const exitPlayed = await page.evaluate(async () => {
+ let played = false;
+ for (let frame = 0; frame < 10; frame += 1) {
+ const panel = document.querySelector<HTMLElement>('.astryx-bottom-sheet');
+ if (panel == null || document.querySelector('dialog[open]') == null) {
+ break;
+ }
+ played ||=
+ panel.style.transitionDuration !== '' ||
+ panel
+ .getAnimations()
+ .some(
+ animation =>
+ animation.effect instanceof KeyframeEffect &&
+ animation.effect
+ .getKeyframes()
+ .some(key => key.translate != null),
+ );
+ await new Promise(resolve => requestAnimationFrame(resolve));
+ }
+ return played;
+ });
+ expect(exitPlayed).toBe(false);
+ await expect(dialog).toBeHidden({timeout: 2_000});
+ const read = async () =>
+ page.evaluate(
+ () =>
+ (
+ window as unknown as {
+ sheetFrames: {
+ samples: [number, number][];
+ upAt: number;
+ done: boolean;
+ };
+ }
+ ).sheetFrames,
+ );
+ await expect
+ .poll(async () => (await read()).done, {timeout: 2_000})
+ .toBe(true);
+ const {samples, upAt} = await read();
+ const before = samples.filter(([at]) => at <= upAt).map(([, top]) => top);
+ const released = Math.max(...before);
+ // Reduced motion runs no transform motion: after the release, no frame
+ // shows the sheet on its way between where the drag left it and rest.
+ const between = samples.filter(
+ ([at, top]) => at > upAt && top > rest.top + 2 && top < released - 2,
+ );
+ const trace = samples.map(([, top]) => Math.round(top)).join(' ');
+ expect(released - rest.top).toBeGreaterThan(100);
+ expect(between, trace).toEqual([]);
+});
+
+interface CloseWatch {
+ /** The backdrop's running opacity transition, ms. */
+ fade: number;
+ /** The close's curve, ms. */
+ close: number;
+ /** Where each started, on the page's clock. */
+ fadeStart: number;
+ closeStart: number;
+ /** When the dialog closed, on the page's clock. */
+ closedAt: number;
+}
+
+/**
+ * The first step of the deprecated switcher's flow, which a swipe closes. The
+ * story opens the flow itself.
+ */
+async function openFlow(page: Page) {
+ return openSheet(
+ page,
+ 'capped',
+ null,
+ 'Set up notifications',
+ 'bottomsheetswitcher',
+ );
+}
+
+/**
+ * A flick that closes Filters, or `open`'s sheet, at `tempo` or the theme's
+ * own: 60 px in `dragMs`, 3,000 px/s by default. It reads what runs: the
+ * backdrop's opacity transition and the close's curve.
+ */
+async function dragClose(
+ page: Page,
+ tempo: number | null,
+ open: typeof openFilters = openFilters,
+ dragMs = 20,
+) {
+ const {dialog, sheet} = await open(page);
+ if (tempo != null) {
+ // The private property a theme that sets tempo writes, on the sheet
+ // itself: the story's theme writes tempo 1 nearer the sheet than :root.
+ await page.addStyleTag({
+ content: `.astryx-bottom-sheet { --_astryx-motion-tempo: ${tempo} !important; }`,
+ });
+ }
+ // Each frame until the dialog closes, keep the latest backdrop fade and the
+ // close's animation. A drag can start fades of its own before the close.
+ await dialog.evaluate((element, holdMs) => {
+ const watch: CloseWatch = {
+ fade: Number.NaN,
+ close: Number.NaN,
+ fadeStart: Number.NaN,
+ closeStart: Number.NaN,
+ closedAt: Number.NaN,
+ };
+ Object.assign(window, {closeWatch: watch});
+ const look = () => {
+ // A switcher step's dialog can hide without a close event.
+ if (
+ !(element as HTMLDialogElement).open ||
+ element.getClientRects().length === 0
+ ) {
+ watch.closedAt = performance.now();
+ return;
+ }
+ const fades = document.getAnimations().filter(animation => {
+ const effect = animation.effect as KeyframeEffect | null;
+ return (
+ animation instanceof CSSTransition &&
+ animation.transitionProperty === 'opacity' &&
+ effect?.target === element &&
+ effect.pseudoElement === '::backdrop'
+ );
+ });
+ const fade = fades[fades.length - 1];
+ if (fade?.startTime != null) {
+ watch.fade = Number(fade.effect?.getTiming().duration);
+ watch.fadeStart = Number(fade.startTime);
+ }
+ const close = element
+ .querySelector('.astryx-bottom-sheet')
+ ?.getAnimations()[0];
+ if (close?.startTime != null) {
+ // The animator holds the end state for holdMs after the curve.
+ watch.close =
+ Number(close.effect?.getComputedTiming().duration) - holdMs;
+ watch.closeStart = Number(close.startTime);
+ }
+ if (Number.isNaN(watch.closedAt)) {
+ requestAnimationFrame(look);
+ }
+ };
+ requestAnimationFrame(look);
+ }, END_HOLD_MS);
+ const cdp = await page.context().newCDPSession(page);
+ await drag(cdp, sheet, 60, dragMs);
+ const read = async () =>
+ page.evaluate(
+ () => (window as unknown as {closeWatch: CloseWatch}).closeWatch,
+ );
+ // A switcher step leaves the accessibility tree at once, and its dialog
+ // closes once the close ends.
+ await expect
+ .poll(async () => Number.isFinite((await read()).closedAt), {
+ timeout: 5_000,
+ })
+ .toBe(true);
+ return read();
+}
+
+/** Expects the scrim's running fade to play on the close's own clock. */
+function expectFadeWithClose(watch: CloseWatch) {
+ const fadeEnd = watch.fadeStart + watch.fade;
+ expect(Math.abs(watch.fade - watch.close)).toBeLessThan(2);
+ // The two end within one frame of each other.
+ expect(Math.abs(fadeEnd - (watch.closeStart + watch.close))).toBeLessThan(17);
+ // The dialog closes a commit after the close ends. So the page is never
+ // clear for long while the dialog still takes taps.
+ expect(watch.closedAt - fadeEnd).toBeLessThan(150);
+}
+
+for (const tempo of [0.75, 1, 1.5]) {
+ test(`a drag's close and its scrim's fade end together, at tempo ${tempo}`, async ({
+ page,
+ }) => {
+ const atOne = await dragClose(page, null);
+ const atTempo = await dragClose(page, tempo);
+ expectFadeWithClose(atTempo);
+ // The close's own curve scales with the tempo, within 5 %. The release
+ // speed, the same for both closes, shapes it a little.
+ const ratio = atTempo.close / atOne.close;
+ expect(ratio).toBeGreaterThan(tempo * 0.95);
+ expect(ratio).toBeLessThan(tempo * 1.05);
+ });
+}
+
+test("a switcher flow's drag close and its scrim's fade end together", async ({
+ page,
+}) => {
+ expectFadeWithClose(await dragClose(page, null, openFlow));
+});
+
+test("a hard flick's close from the top snap point and its scrim's fade end together", async ({
+ page,
+}) => {
+ // 4,000 px/s. Snap points styles its fade only on the next frame.
+ expectFadeWithClose(
+ await dragClose(
+ page,
+ null,
+ async p =>
+ openSheet(p, 'snap-points', 'Open nearby places', 'Nearby places'),
+ 15,
+ ),
+ );
+});
diff --git a/packages/core/src/BottomSheet/__tests__/BottomSheetScrimClock.a11y.browser.spec.ts b/packages/core/src/BottomSheet/__tests__/BottomSheetScrimClock.a11y.browser.spec.ts
new file mode 100644
index 0000000000..b111de1cef
--- /dev/null
+++ b/packages/core/src/BottomSheet/__tests__/BottomSheetScrimClock.a11y.browser.spec.ts
@@ -0,0 +1,118 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+// @pr-a11y release-only
+
+/**
+ * @file BottomSheetScrimClock.a11y.browser.spec.ts
+ * @input The built BottomSheet Showcase story, on a phone viewport with
+ * real touch input through the interaction harness
+ * @output Real-engine proof that a touch drag's close and the fade that
+ * clears its scrim start at the same time on the document timeline. It
+ * runs in Chromium and in WebKit, which reports the backdrop's fade on the
+ * dialog
+ * @position Chromium and WebKit; the Chromium release spec measures the
+ * same pair end to end
+ */
+
+import {expect, test} from '@astryxdesign/a11y-spec/playwright';
+import {
+ DEFAULT_STORYBOOK_DIR,
+ serveStorybook,
+ type StaticServer,
+} from '@astryxdesign/a11y-spec/storybook';
+import {drag, touchDriver} from '@astryxdesign/interaction-harness';
+
+let storybook: StaticServer;
+test.beforeAll(async () => {
+ storybook = await serveStorybook(
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
+ );
+});
+test.afterAll(async () => {
+ await storybook?.close();
+});
+
+test.use({viewport: {width: 390, height: 844}, hasTouch: true});
+
+test("a touch drag's close and its scrim's fade start together", async ({
+ page,
+}) => {
+ await page.goto(
+ `${storybook.origin}/iframe.html?id=core-bottomsheet--showcase&viewMode=story`,
+ );
+ await page.getByRole('button', {name: 'Open sheet'}).click();
+ const dialog = page.getByRole('dialog', {name: 'Filters'});
+ await expect(dialog).toBeVisible();
+ const sheet = dialog.locator('.astryx-bottom-sheet').first();
+ await expect
+ .poll(async () =>
+ page.evaluate(
+ () =>
+ !document
+ .getAnimations()
+ .some(animation => animation.playState === 'running'),
+ ),
+ )
+ .toBe(true);
+ // Each frame, keep the start of the close and of the fade that clears the
+ // scrim. WebKit reports that fade on the dialog, with no pseudo-element.
+ await dialog.evaluate(element => {
+ const watch = {fade: Number.NaN, close: Number.NaN, done: false};
+ Object.assign(window, {clockWatch: watch});
+ // The fade can start on its own first and take the close's start a few
+ // frames later. Sampling ends once it has, or five frames after both
+ // start.
+ let framesSinceBoth = 0;
+ const look = () => {
+ for (const animation of document.getAnimations()) {
+ const effect = animation.effect as KeyframeEffect | null;
+ if (
+ effect?.target === element &&
+ (animation as CSSTransition).transitionProperty === 'opacity' &&
+ Number(effect.getKeyframes().at(-1)?.opacity) === 0 &&
+ animation.startTime != null
+ ) {
+ watch.fade = Number(animation.startTime);
+ }
+ }
+ const close = element
+ .querySelector('.astryx-bottom-sheet')
+ ?.getAnimations()[0];
+ if (close?.startTime != null) {
+ watch.close = Number(close.startTime);
+ }
+ if (Number.isFinite(watch.fade) && Number.isFinite(watch.close)) {
+ framesSinceBoth += 1;
+ }
+ if (Math.abs(watch.fade - watch.close) < 1 || framesSinceBoth > 5) {
+ watch.done = true;
+ } else {
+ requestAnimationFrame(look);
+ }
+ };
+ requestAnimationFrame(look);
+ });
+ const box = await sheet.boundingBox();
+ if (box == null) {
+ throw new Error('no sheet box');
+ }
+ const x = Math.round(box.x + box.width / 2);
+ // A short flick down from the grabber, about 1,500 px/s: the sheet closes,
+ // and the drag leaves the scrim where it was.
+ const driver = await touchDriver(page);
+ const y = Math.round(box.y + 12);
+ await driver.play(drag({x, y}, {x, y: y + 60}, {durationMs: 40}), {
+ pacing: 'spacing',
+ });
+ const read = async () =>
+ page.evaluate(
+ () =>
+ (
+ window as unknown as {
+ clockWatch: {fade: number; close: number; done: boolean};
+ }
+ ).clockWatch,
+ );
+ await expect.poll(async () => (await read()).done).toBe(true);
+ const {fade, close} = await read();
+ expect(Math.abs(fade - close)).toBeLessThan(1);
+});
diff --git a/packages/core/src/BottomSheet/useSheetGestures.test.ts b/packages/core/src/BottomSheet/useSheetGestures.test.ts
index b86150c2a9..af1e6a6ce2 100644
--- a/packages/core/src/BottomSheet/useSheetGestures.test.ts
+++ b/packages/core/src/BottomSheet/useSheetGestures.test.ts
@@ -103,6 +103,16 @@ function down(hook: Hook, y: number, t: number, target: HTMLElement) {
hook.result.current.handleProps.onPointerDown(pointerEvent(y, t, target)),
);
}
+/** A touch press on the handle: a drag's close then plays the close spring. */
+function touchDown(hook: Hook, y: number, t: number, target: HTMLElement) {
+ act(() => hook.result.current.sheetRef(target));
+ act(() =>
+ hook.result.current.handleProps.onPointerDown({
+ ...pointerEvent(y, t, target),
+ pointerType: 'touch',
+ } as unknown as React.PointerEvent),
+ );
+}
function move(hook: Hook, y: number, t: number, target: HTMLElement) {
act(() =>
hook.result.current.handleProps.onPointerMove(pointerEvent(y, t, target)),
@@ -643,6 +653,47 @@ describe('useSheetGestures', () => {
expect(onDismiss).not.toHaveBeenCalled();
});
+ describe("a drag's close", () => {
+ it('hands the panel the distance left and the release speed after a touch drag closes it', () => {
+ const {hook, onDismiss} = setup();
+ const t = makeTarget();
+ touchDown(hook, 0, 0, t);
+ move(hook, 100, 50, t);
+ move(hook, 200, 100, t);
+ // The host takes the close in the same update, as a controlled host does.
+ act(() => {
+ hook.result.current.handleProps.onPointerUp(pointerEvent(200, 102, t));
+ hook.rerender({isOpen: false, isOpenRequested: false, onDismiss});
+ });
+ expect(onDismiss).toHaveBeenCalledTimes(1);
+ // 200px left to travel, at the release's 2,000 px/s.
+ expect(hook.result.current.dragExit).toEqual({
+ distance: 200,
+ velocity: 2000,
+ });
+ });
+
+ it('keeps the stylesheet exit for a close that no drag started', () => {
+ const {hook, onDismiss} = setup();
+ hook.rerender({isOpen: false, isOpenRequested: false, onDismiss});
+ expect(hook.result.current.dragExit).toBeNull();
+ });
+
+ it('gives a mouse drag that closes the sheet the stylesheet exit', () => {
+ const {hook, onDismiss} = setup();
+ const t = makeTarget();
+ down(hook, 0, 0, t);
+ move(hook, 100, 50, t);
+ move(hook, 200, 100, t);
+ act(() => {
+ hook.result.current.handleProps.onPointerUp(pointerEvent(200, 102, t));
+ hook.rerender({isOpen: false, isOpenRequested: false, onDismiss});
+ });
+ expect(onDismiss).toHaveBeenCalledTimes(1);
+ expect(hook.result.current.dragExit).toBeNull();
+ });
+ });
+
describe('pinch', () => {
// A second finger is a pinch, and pinch-zoom belongs to the browser.
it('declares pinch-zoom on the sliding surface and the handle', () => {
diff --git a/packages/core/src/BottomSheet/useSheetGestures.ts b/packages/core/src/BottomSheet/useSheetGestures.ts
index a484f85d2b..5cb66230b9 100644
--- a/packages/core/src/BottomSheet/useSheetGestures.ts
+++ b/packages/core/src/BottomSheet/useSheetGestures.ts
@@ -413,6 +413,14 @@ export interface UseSheetGesturesOptions {
hasFixedHeight?: boolean;
}
+/** A drag's close: the distance left to the closed position and the speed. */
+export interface SheetDragExit {
+ /** px from the release position to the closed position. */
+ readonly distance: number;
+ /** The release velocity, px/s, positive toward closed. */
+ readonly velocity: number;
+}
+
export interface SheetContentProps {
style: CSSProperties;
}
@@ -486,6 +494,11 @@ export interface UseSheetGesturesResult {
* cross-fades on every pointer, so the exit's motion needs to know.
*/
isDismissedByTouchDrag: boolean;
+ /**
+ * The exit a touch drag's release started: the distance left to travel and
+ * the release speed. Null for a close that no touch drag started.
+ */
+ dragExit: SheetDragExit | null;
/**
* The sheet's offset right now, in px: the settled detent at rest, the live
* position during a drag. Written per input sample without a render; read
@@ -568,6 +581,7 @@ export function useSheetGestures({
const [touchDragDismissal, setTouchDragDismissal] = useState<{
isTouch: boolean;
pending: boolean;
+ exit: SheetDragExit | null;
} | null>(null);
// The render that spends a refused request counts it. The layout effect
// below answers each count.
@@ -578,20 +592,19 @@ export function useSheetGestures({
setTouchDragDismissal(null);
setRefusedDismissalCount(count => count + 1);
} else {
- setTouchDragDismissal({
- isTouch: touchDragDismissal.isTouch,
- pending: false,
- });
+ setTouchDragDismissal({...touchDragDismissal, pending: false});
}
} else if (isOpenRequested) {
setTouchDragDismissal(null);
}
}
- const isDismissedByTouchDrag =
+ const isDismissedByDrag =
touchDragDismissal != null &&
!touchDragDismissal.pending &&
- touchDragDismissal.isTouch &&
!isOpenRequested;
+ const isDismissedByTouchDrag =
+ isDismissedByDrag && touchDragDismissal.isTouch;
+ const dragExit = isDismissedByDrag ? touchDragDismissal.exit : null;
// Whether the drag in flight has moved the sheet off its base detent. One
// state change per drag, for hosts that react to travel beginning.
const [isTraveling, setIsTraveling] = useState(false);
@@ -1181,43 +1194,54 @@ export function useSheetGestures({
}
};
+ const closeSheet = (exit: SheetDragExit | null) => {
+ if (!canDismissRef.current) {
+ settleAt(maxOffset);
+ return;
+ }
+ prepareScrollAreaSettle(
+ baseLayoutOffset,
+ baseOffset,
+ baseLayoutOffset,
+ baseLayoutOffset,
+ baseLayoutOffset,
+ naturalEndGap,
+ false,
+ );
+ restingScrimOpacityRef.current = scrimOpacityForOffset(
+ baseOffset,
+ offsets,
+ dismissOffset,
+ peekOffset,
+ );
+ setTouchDragDismissal({isTouch, pending: true, exit});
+ onDismissRef.current();
+ };
// A release that would coast past the dismiss line closes the sheet: a
// throw from anywhere, or a slow drag that already crossed it.
if (dir > 0 && projected > dismissOffset) {
- if (canDismissRef.current) {
- prepareScrollAreaSettle(
- baseLayoutOffset,
- baseOffset,
- baseLayoutOffset,
- baseLayoutOffset,
- baseLayoutOffset,
- naturalEndGap,
- false,
- );
- restingScrimOpacityRef.current = scrimOpacityForOffset(
- baseOffset,
- offsets,
- dismissOffset,
- peekOffset,
- );
- setTouchDragDismissal({isTouch, pending: true});
- onDismissRef.current();
- } else {
- settleAt(maxOffset);
- }
+ closeSheet(
+ isTouch
+ ? {
+ distance: Math.max(0, height - offset),
+ velocity: velocity * 1000,
+ }
+ : null,
+ );
return;
}
// Settle to the detent nearest where the release would coast to, in the
// drag direction (never back past the starting detent), de-duped and
// direction-clamped by the util. A throw upward projects past the
// tallest detent and lands on it.
- const target = resolveSettleOffset(
- Math.min(Math.max(projected, 0), maxOffset),
- offsets,
- dir,
- baseOffset,
+ settleAt(
+ resolveSettleOffset(
+ Math.min(Math.max(projected, 0), maxOffset),
+ offsets,
+ dir,
+ baseOffset,
+ ),
);
- settleAt(target);
},
[prepareScrollAreaSettle, recordSettledLayoutOffset, resolveDetents],
);
@@ -1968,6 +1992,7 @@ export function useSheetGestures({
isDragging,
isTraveling,
isDismissedByTouchDrag,
+ dragExit,
activeOffsetRef,
sheetHeight,
scrollPreservationInset,
diff --git a/packages/core/src/motion/resolveMotion.tempo.test.ts b/packages/core/src/motion/resolveMotion.tempo.test.ts
index 81de8ce9e5..0f65f25fba 100644
--- a/packages/core/src/motion/resolveMotion.tempo.test.ts
+++ b/packages/core/src/motion/resolveMotion.tempo.test.ts
@@ -8,15 +8,22 @@
* spring keeps its shape and takes tempo times as long in each of its
* forms. A duration scales. A curve, a part that follows a finger and a
* busy loop stay as measured. A role resolves to one object per tempo and
- * is never scaled twice. The animator plays the slowed spring
+ * is never scaled twice. The animator plays the slowed spring. A CSS part
+ * timed from a spring lasts the resolved spring's settling duration, or
+ * as long as the animator plays one move on it
* @position Testing for /packages/core/src/motion/resolveMotion.ts (the
* browser proof: themeTempo.interaction.browser.spec.ts)
*/
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
-import {createMotionEngine} from './animator';
-import {resolveMotion} from './resolveMotion';
-import {solveSpring, toSpring} from './spring';
+import {createMotionEngine, SETTLE_THRESHOLD} from './animator';
+import {resolveMotion, resolveSettleMs} from './resolveMotion';
+import {
+ settlingDuration,
+ solveSpring,
+ toSpring,
+ type SpringDescription,
+} from './spring';
import {
progressBar,
registerProgressBarTable,
@@ -161,6 +168,67 @@ describe("resolveMotion at the theme's tempo (spec:AST-108 FR3)", () => {
});
});
+describe('a CSS part timed from its spring', () => {
+ const settleMs = (spring: SpringDescription) =>
+ settlingDuration(toSpring(spring)) * 1000;
+
+ it("lasts the role's settling duration where no theme sets a tempo", () => {
+ const target = element();
+ expect(resolveSettleMs(target, springs.settle)).toBe(
+ settleMs(springs.settle),
+ );
+ // SwiftUI's smooth spring (0.5 s, no bounce) settles in about 0.6 s.
+ expect(resolveSettleMs(target, springs.settle)).toBeGreaterThan(400);
+ expect(resolveSettleMs(target, springs.settle)).toBeLessThan(900);
+ });
+
+ it('takes tempo times as long with the spring it plays with', () => {
+ const target = element();
+ const plain = resolveSettleMs(target, springs.settle);
+ tempo = '1.5';
+ expect(resolveSettleMs(target, springs.settle)).toBeCloseTo(plain * 1.5, 6);
+ expect(resolveSettleMs(target, springs.settle)).toBe(
+ settleMs(resolveMotion(target, springs.settle)),
+ );
+ });
+
+ it('stays as measured for a finger-following role, and for a spring that is not a role', () => {
+ tempo = '1.5';
+ const target = element();
+ expect(resolveSettleMs(target, springs.fingerTracking)).toBe(
+ settleMs(springs.fingerTracking),
+ );
+ const inline = {response: 0.4, dampingRatio: 0.9};
+ expect(resolveSettleMs(target, inline)).toBe(settleMs(inline));
+ });
+
+ it('lasts as long as the animator plays one move on the spring', () => {
+ tempo = '1.5';
+ const target = element();
+ const animator = createMotionEngine(target, {now: () => 0});
+ const close = animator.animate(
+ {y: 400},
+ {spring: springs.sheetDismissSwipe, velocity: {y: 3000}},
+ {at: 0},
+ );
+ const move = {
+ from: 0,
+ to: 400,
+ velocity: 3000,
+ epsilon: SETTLE_THRESHOLD.y,
+ };
+ const curveMs = (close.curve('y')?.duration ?? Number.NaN) * 1000;
+ expect(
+ resolveSettleMs(target, springs.sheetDismissSwipe, move),
+ ).toBeCloseTo(curveMs, 6);
+ // A long, fast move settles later than a unit move from rest.
+ expect(curveMs).toBeGreaterThan(
+ resolveSettleMs(target, springs.sheetDismissSwipe),
+ );
+ animator.dispose();
+ });
+});
+
describe('the animator', () => {
it("plays a role's spring at the theme's tempo", () => {
tempo = '1.5';
diff --git a/packages/core/src/motion/resolveMotion.ts b/packages/core/src/motion/resolveMotion.ts
index 8e6af5fcb8..c38a409416 100644
--- a/packages/core/src/motion/resolveMotion.ts
+++ b/packages/core/src/motion/resolveMotion.ts
@@ -5,7 +5,9 @@
* @input A motion role: a spring or curve of a registered motion table, or a
* table group and the key of one of its values. The element the motion
* plays on, for its theme's tempo (themeTempo.ts)
- * @output resolveMotion: the role's value at the theme's tempo
+ * @output resolveMotion: the role's value at the theme's tempo.
+ * resolveSettleMs: how long a spring role, or one move on it, takes to
+ * settle there, for a CSS part that plays with it
* @position Motion foundation; the animator resolves every spring and curve
* it is handed with it, and components resolve the durations they time
* with it
@@ -29,7 +31,12 @@
import {motionRoleIn, motionRoleOf} from './roles';
import {isSpring} from './roleValue';
import type {MotionCurvePoints} from './roles';
-import type {SpringDescription} from './spring';
+import {
+ settlingDuration,
+ solveSpring,
+ toSpring,
+ type SpringDescription,
+} from './spring';
import {themeTempo} from './themeTempo';
/**
@@ -137,3 +144,38 @@ export function resolveMotion(
}
return isSpring(value) ? springAtTempo(value, tempo) : value;
}
+
+/** One move a spring plays, as the animator plays it. */
+export interface SpringMove {
+ readonly from: number;
+ readonly to: number;
+ /** The start velocity, in units per second. 0 by default. */
+ readonly velocity?: number;
+ /** The move is over once it stays this close to `to`. */
+ readonly epsilon: number;
+}
+
+/**
+ * How long `spring` takes to settle, in milliseconds, at the tempo of the
+ * theme `element` is in. A CSS part that plays with the spring takes this
+ * duration, such as a scrim's fade under a sheet. Then the two start and land
+ * together on one clock. Without `move`, it is the resolved spring's settling
+ * duration. With `move`, it is how long that move plays. The animator times
+ * its moves the same way, so a part that plays with one passes the move. A
+ * fixed role, or a spring that is not a role, gives its own.
+ *
+ * @example
+ * ```
+ * scrim.style.transitionDuration = `${resolveSettleMs(sheet, springs.settle)}ms`;
+ * ```
+ */
+export function resolveSettleMs(
+ element: Element | null | undefined,
+ spring: SpringDescription,
+ move?: SpringMove,
+): number {
+ const resolved = toSpring(resolveMotion(element, spring));
+ return move == null
+ ? settlingDuration(resolved) * 1000
+ : solveSpring(resolved, move).settleTime(move.epsilon) * 1000;
+}
diff --git a/packages/core/src/motion/uikit/springRows.test.ts b/packages/core/src/motion/uikit/springRows.test.ts
index 01debd8ad2..25149e01c9 100644
--- a/packages/core/src/motion/uikit/springRows.test.ts
+++ b/packages/core/src/motion/uikit/springRows.test.ts
@@ -33,10 +33,12 @@ function bundle(entry: string): string {
);
}
-// Numbers only one row carries, as a minified bundle writes them.
+// Values only one row carries, as a minified bundle writes them. The two
+// sheet rows share a response, so their damping tells them apart.
const KEYBOARD = '555.0265';
const ALERT = '522.35';
-const SHEET_DETENT = '.3441442326';
+const SHEET_DETENT = 'response:.3441442326,dampingRatio:1}';
+const SHEET_DISMISS_SWIPE = 'response:.3441442326,dampingRatio:.8}';
const FINGER_TRACKING = '.86';
const DIRECT_CHANGE = '.825';
@@ -64,6 +66,7 @@ describe('spring rows', () => {
);
expect(roles).toContain(FINGER_TRACKING);
expect(roles).toContain(DIRECT_CHANGE);
+ expect(roles).toContain(SHEET_DISMISS_SWIPE);
for (const other of [KEYBOARD, ALERT, SHEET_DETENT]) {
expect(roles).not.toContain(other);
}
diff --git a/packages/core/src/motion/uikit/springs.ts b/packages/core/src/motion/uikit/springs.ts
index 5bdd5e6c4f..5fbb5653c4 100644
--- a/packages/core/src/motion/uikit/springs.ts
+++ b/packages/core/src/motion/uikit/springs.ts
@@ -243,10 +243,13 @@ export const SHEET_RELEASE_FAST_SPRING = {
* iPhone 17 Pro, CASpringAnimation dump (300 pt swipe in 0.15 s:
* stiffness 333.333, damping 29.212), Oct 23 2026
*/
-export const SHEET_DISMISS_SWIPE_SPRING = {
- response: 0.3441442326,
- dampingRatio: 0.8,
-} as const;
+export const SHEET_DISMISS_SWIPE_SPRING = /* @__PURE__ */ springRole(
+ 'sheetDismissSwipe',
+ {
+ response: 0.3441442326,
+ dampingRatio: 0.8,
+ } as const,
+);
// ---------------------------------------------------------------------
// Alerts, action sheets, menus
@@ -572,6 +575,7 @@ const SPRING_ROLES = {
menuClose: MENU_CLOSE_SPRING,
subMenuOpen: SUB_MENU_OPEN_SPRING,
subMenuBack: SUB_MENU_BACK_SPRING,
+ sheetDismissSwipe: SHEET_DISMISS_SWIPE_SPRING,
contextMenuLift: CONTEXT_MENU_LIFT_SPRING,
contextMenuDismiss: CONTEXT_MENU_DISMISS_SPRING,
contextMenuMorph: CONTEXT_MENU_MORPH_SPRING,
@@ -585,7 +589,7 @@ const SPRING_ROLES = {
* (motion/roles.ts), by their row names (`springs.settle`). Every other
* spring, UIKit's menu spring under Reduce Motion and the keyboard's
* included, is not a role. Each role row registers itself when it loads, so
- * a call registers nothing new. A call still puts all 18 role rows in the
+ * a call registers nothing new. A call still puts all 19 role rows in the
* caller's bundle.
*/
export function registerSpringsTable(): void {