Skip to content

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

TypeScript

fix(core): a list row's touch press release runs on the compositor (#9762)

Cindy Zhang298bafbc104f
diff --git a/.changeset/list-row-press-compositor.md b/.changeset/list-row-press-compositor.md
new file mode 100644
index 0000000000..75ad1a8430
--- /dev/null
+++ b/.changeset/list-row-press-compositor.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] A list row's touch press release keeps fading while the page runs script, once the release has started. `ListItem`, `Item` and `TreeList` rows used to freeze mid-fade until the main thread was free, and every frame of the fade repainted the row; the release now runs on the compositor, with the same color, clock and curve as before. Script that runs in the tap's own handlers, before the next frame, still holds the row pressed until it ends. Under a finger, while a row is pressed and through its release, the press paints on the row's `::before` and the row is its own stacking context; at rest nothing of it applies, so a row's own `::before` decoration and its children's stacking are as they were. During a press the layer is the row's `::before`, and any `::before` property a caller sets, from `xstyle` (which `Item` composes after the layer) or from a stylesheet, wins over the layer's: a decoration with its own size and background jumps to the row's corner, and the row shows no pressed fill until the release ends. Decoration that should stay through a press belongs on `::after` or a child element. With a mouse or trackpad the row is unchanged: no layer and no new stacking context.
+
+@vjeux
diff --git a/docs/specs/components/List/List.spec.md b/docs/specs/components/List/List.spec.md
index b0ae14cc3f..5dec5d8576 100644
--- a/docs/specs/components/List/List.spec.md
+++ b/docs/specs/components/List/List.spec.md
@@ -43,15 +43,15 @@ system_specs:
## Contract at a glance
-| Area | Contract |
-| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Public contract | Optional `edge?: 'padded' \| 'flush' \| 'outset' \| 'bleed'`, default `'padded'`. Deprecated `edgeCompensation?: 'inline'` resolves to `'outset'`. Optional `reorderable` takes the object `createReorderable` returns, and ListItem's `itemKey` identifies each row (`spec:AST-103`). Optional `animatedLayout` takes the handle `useAnimatedLayout` returns (`spec:AST-105`). |
-| Behavior | One edge treatment applies to every ListItem row and decides where row content and row paint sit relative to the list's edges and the host's padding. With `reorderable`, rows reorder by dragging a handle or through reorder mode (`spec:AST-103` FR3, FR4). Under a coarse pointer a row's press follows the cell profile (`spec:AST-094` FR11); with `animatedLayout`, row updates animate (`spec:AST-105`). A row menu opens from the row's own `<li>` on the context request (FR13). |
-| End-user impact | Row text can share the line of the list header and a heading above, with row paint stopping at the text, reaching into the host padding, or reaching the host edges. Touch users get a 44 px row target (FR10) and the cell press (FR11); with `animatedLayout`, row updates animate for every pointer (FR12). A row with a menu opens it by a long press, a right click, or Shift+F10, or through its More actions button (FR13). |
-| Builder impact | One `edge` choice per list. `flush` works anywhere; `outset` and `bleed` act only inside a host that publishes container padding. Passing an `animatedLayout` handle is one new choice, and a row menu is the other: the caller passes a ListItem's ref to `useContextMenu` (FR13), and who draws a plain row's More actions button is open (OQ2); and rows animate only with an `itemKey`; the touch target and press need none. |
-| Compatibility/readiness | Additive; omission keeps current geometry; `edgeCompensation` keeps working with a codemod to `edge`. `reorderable` and `itemKey` are additive and stable, specified and not implemented yet; without them nothing changes. `animatedLayout` is additive and specified, not implemented yet. The touch target (FR10) and the press's compositor release (FR11) are specified, not implemented yet, and change nothing under a fine pointer. Row menus (FR13) are additive and specified, not implemented yet. |
-| Review checks | Reject header movement, row paint past the host's padding edge, duplicated padding values, physical-edge logic, automatic opt-in, a ListItem-level edge prop, or a second prop that can contradict `edge`. |
-| Governing rules | `architecture:container-padding/INV3`, `INV9–INV11`; `spec:AST-002/DEC-1–DEC-2`; `spec:AST-017/FR4`; `spec:AST-057/FR9`. `spec:AST-103`. `spec:AST-094` FR4, FR5, FR11, FR13; `spec:AST-105` FR1–FR5, FR8. `spec:AST-107` FR8 (row menus). |
+| Area | Contract |
+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Public contract | Optional `edge?: 'padded' \| 'flush' \| 'outset' \| 'bleed'`, default `'padded'`. Deprecated `edgeCompensation?: 'inline'` resolves to `'outset'`. Optional `reorderable` takes the object `createReorderable` returns, and ListItem's `itemKey` identifies each row (`spec:AST-103`). Optional `animatedLayout` takes the handle `useAnimatedLayout` returns (`spec:AST-105`). |
+| Behavior | One edge treatment applies to every ListItem row and decides where row content and row paint sit relative to the list's edges and the host's padding. With `reorderable`, rows reorder by dragging a handle or through reorder mode (`spec:AST-103` FR3, FR4). Under a coarse pointer a row's press follows the cell profile (`spec:AST-094` FR11); with `animatedLayout`, row updates animate (`spec:AST-105`). A row menu opens from the row's own `<li>` on the context request (FR13). |
+| End-user impact | Row text can share the line of the list header and a heading above, with row paint stopping at the text, reaching into the host padding, or reaching the host edges. Touch users get a 44 px row target (FR10) and the cell press (FR11); with `animatedLayout`, row updates animate for every pointer (FR12). A row with a menu opens it by a long press, a right click, or Shift+F10, or through its More actions button (FR13). |
+| Builder impact | One `edge` choice per list. `flush` works anywhere; `outset` and `bleed` act only inside a host that publishes container padding. Passing an `animatedLayout` handle is one new choice, and a row menu is the other: the caller passes a ListItem's ref to `useContextMenu` (FR13), and who draws a plain row's More actions button is open (OQ2); and rows animate only with an `itemKey`; the touch target and press need none. |
+| Compatibility/readiness | Additive; omission keeps current geometry; `edgeCompensation` keeps working with a codemod to `edge`. `reorderable` and `itemKey` are additive and stable, specified and not implemented yet; without them nothing changes. `animatedLayout` is additive and specified, not implemented yet. The touch target (FR10) is specified, not implemented yet; the press's compositor release (FR11) is implemented. Neither changes anything under a fine pointer. Row menus (FR13) are additive and specified, not implemented yet. |
+| Review checks | Reject header movement, row paint past the host's padding edge, duplicated padding values, physical-edge logic, automatic opt-in, a ListItem-level edge prop, or a second prop that can contradict `edge`. |
+| Governing rules | `architecture:container-padding/INV3`, `INV9–INV11`; `spec:AST-002/DEC-1–DEC-2`; `spec:AST-017/FR4`; `spec:AST-057/FR9`. `spec:AST-103`. `spec:AST-094` FR4, FR5, FR11, FR13; `spec:AST-105` FR1–FR5, FR8. `spec:AST-107` FR8 (row menus). |
This table is a review projection; the body below is authoritative.
@@ -130,7 +130,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| FR8 | `outset` and `bleed` are valid only under a host state whose published inline inset matches its applied padding: a visually neutral host, such as a Layout region with explicit padding or a padded ScrollableArea, or the content area of a Card, Section (any variant), Dialog, or BottomSheet. Those hosts bound their padding with a border, background, or clip; FR6 keeps row paint inside the padding edge, so it never covers the border or changes the host's outline. Automatic LayoutContent/LayoutPanel states with a known publication mismatch are not eligible until that gap is fixed, and Drawer's content area is not admitted until it has its own evidence. | `architecture:container-padding/INV8–INV11`; real-browser evidence in each admitted host | Accepted contract |
| FR9 | The list element containing the rows MUST clip in the inline axis with `overflow-inline: clip`, never `hidden`, except for static Markdown document lists that expose no swipe actions (DEC-5). Those Markdown lists, ordered or unordered, MAY use visible inline overflow so their own or descendant number markers remain whole while retaining AST-061 FR11's text starts and nested insets. General Lists and any collection with swipe-capable rows MUST retain the clip. Under `outset` and `bleed` its inline edges MUST reach the host's padding edge, so the clip never cuts resting row paint and a swiped row paints no further than that edge. | `spec:AST-057/FR9`; `component:List/DEC-5`; `spec:AST-061/FR11` | Verified by `List.test.tsx` and real-browser geometry |
| FR10 | Under a coarse primary pointer (`spec:AST-094` FR13), every ListItem row MUST offer a hit target at least 44 px tall, through its padding or an invisible hit area, with no visual change, where its neighbors leave room: the hit area never overlaps a neighboring row's or control's target, and between close neighbors it is clamped to half the gap; row height and geometry stay as they are at every density. A fine pointer keeps today's hit target. | Owner decision, 2026-10-26: no row-height change, a 44 px touch target | Accepted contract |
-| FR11 | Under a coarse primary pointer, an interactive row's press MUST follow the cell profile (`spec:AST-094` FR11): it paints the `--color-overlay-pressed` token above the row's background and below its content without adding an element, and its release fades over the press model's release duration and curve on the compositor (`spec:AST-094` FR5). The row's dividers stay drawn while it is pressed, in every theme. At rest the row's paint and stacking are as they were. | `spec:AST-094` FR5, FR11 | Accepted contract |
+| FR11 | Under a coarse primary pointer, an interactive row's press MUST follow the cell profile (`spec:AST-094` FR11): it paints the `--color-overlay-pressed` token above the row's background and below its content without adding an element, and its release fades over the press model's release duration and curve on the compositor (`spec:AST-094` FR5). The row's dividers stay drawn while it is pressed, in every theme. At rest the row's paint and stacking are as they were. Under the touch presentation, an interactive Item, ListItem or TreeList row uses its `::before` as the press layer, and a pressed row's divider keeps its resting colour. A caller's own `::before` on such a row merges into the press layer only while it is pressed; use `::after` or a child for decoration. | `spec:AST-094` FR5, FR11; `component:List/DEC-6` | Accepted contract |
| FR12 | List MUST take an `animatedLayout` handle (`spec:AST-105` FR1) and report each row inserted, removed, or moved between renders. With a handle, an inserted row enters, a removed row collapses in place, inert and hidden from assistive technology until it is gone, and a row crossing rows moving the other way rides above them on the list's surface, while the rows after a change glide to their new places (`spec:AST-105` FR3), all starting on one frame on the shared motion role (`spec:AST-105` FR4). Without a handle the list changes at once (`spec:AST-105` FR2). A row's identity is its `itemKey` (`spec:AST-103` DEC-4); a row without one changes at once. With a handle, a row also reports a change to its start or end content: content that appears enters, content that leaves exits (a slot that sets the row's height hides at once instead, and the row's other content and the rows after it take their final places at once, as `spec:AST-105`'s Coverage states), content replaced in the same slot swaps in place (`spec:AST-105` FR4, FR8), and the row's other content glides within the row; a slot whose content changes without changing size does not animate. The reorder handle's appearance (`spec:AST-103`) is such a change. A slot control that leaves is inert and hidden from assistive technology as its exit starts; if it held focus, focus moves to the row's focus target (or to the row, which takes focus programmatically for the handoff) without scrolling. | `spec:AST-105` FR1–FR5; `spec:AST-103` DEC-4; `spec:AST-105` FR8; `spec:AST-103` FR2 (the handle renders only with `reorderable`) | Accepted contract |
| FR13 | A row menu on a ListItem attaches to the row's own `<li>`, keeping `ul > li` with no wrapper element: the caller passes the ListItem's ref to `useContextMenu` (`spec:AST-107` FR8), with no ListItem prop of its own; the whole row is its hit area, it opens on the context request (a long press, a right click, or Shift+F10), under a finger, the row takes the press paint (FR11; on a plain row, part of OQ2) and lifts as the menu grows from it, `useContextMenu` lifting the element it is attached to (`spec:AST-094` FR31, FR33), while a mouse, the keyboard, and `presentation: 'popover'` open the released menu without the lift (`spec:AST-094` FR41), and focus returns to the row's focus target when the menu closes. A row that is already focusable (`onClick` or `href`) takes Shift+F10 and the context-menu key directly, and a row with an `interactiveRef` takes them on that element; neither shows a "More actions" button; a row with none of these shows a visible "More actions" button named with the row's label, such as "More actions for Inbox", its keyboard and screen-reader path to the menu. When a menu opens, focus moves into it; when it closes, focus returns to the row's focus target, or to the "More actions" button on a row that shows one. Who moves focus there, since `useContextMenu` returns focus to the `<li>`, which takes none, is part of OQ2. A reorderable row always has its handle (`spec:AST-103` FR3), so when it also has a row menu, a hold on the handle picks the row up and a hold anywhere else on the row opens the menu. | Owner decision, 2026-10-26; `spec:AST-107` FR8 | Accepted contract |
@@ -310,13 +310,22 @@ clipping or change list source, numbering, marker styles, or public APIs.
Rejected: widening a finite marker gutter, because it only moves the counter-width failure threshold.
-## Open questions
+### DEC-6 — A touch press takes the row's `::before`
+
+**Reference:** `component:List/DEC-6`
+
+**Decider:** cixzhang, 2026-10-25
-- **OQ1 — A caller's `::before` through a press.** The press paint takes the
- row's `::before` while the row is pressed, so a caller's decoration there
- is hidden for that time: (a) keep that, and document decorating a row with
- a child; or (b) require the press paint to leave a caller's `::before`
- intact.
+Under the touch presentation, an interactive row paints its press on its own
+`::before`, the one paint the compositor can fade while script runs. A
+caller's own `::before` on the row merges into that layer only while the row
+is pressed, so decoration that must stay through a press goes on `::after` or
+a child. A pressed row's divider keeps its resting colour.
+
+Rejected: leaving a caller's `::before` intact through a press, because the
+row then needs a second element or a main-thread paint for its press.
+
+## Open questions
- **OQ2 — Who renders a plain row's More actions button and returns focus.** `useContextMenu`
returns `open` and `close` but no trigger, so FR13's More actions button on a
diff --git a/packages/core/src/Item/Item.tsx b/packages/core/src/Item/Item.tsx
index 509ed694df..287719efc2 100644
--- a/packages/core/src/Item/Item.tsx
+++ b/packages/core/src/Item/Item.tsx
@@ -4,7 +4,8 @@
/**
* @file Item.tsx
- * @input Uses React, ReactNode, StyleXStyles, theme tokens, useClickableContainer
+ * @input Uses React, ReactNode, StyleXStyles, theme tokens, useClickableContainer,
+ * the shared press overlays and the compositor press layer
* @output Exports Item component, ItemProps type; publishes the shared inline inset.
* Only numbered composing rows keep their start/label/end slots in one flex
* group, through Item's private exact-marker scope; other marked rows keep
@@ -62,6 +63,7 @@ import {useDevWarning} from '../hooks/useDevWarning';
import {themeProps} from '../utils/themeProps';
import {focusOutlineProps} from '../utils/focusOutline.stylex';
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
+import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
import {usePressFeedback} from '../hooks/usePressFeedback';
import type {ItemSwipeBridge} from './ItemSwipeLayer';
@@ -533,7 +535,6 @@ const styles = stylex.create({
// zoomable (WCAG 1.4.4). The hover transition keeps its own clock beside
// the transform's.
swipeRoot: {
- isolation: 'isolate',
touchAction: 'pan-y pinch-zoom',
transform: `translate3d(${SWIPE_TRAVEL}, 0, 0)`,
transitionProperty: 'background-color, transform',
@@ -926,6 +927,10 @@ export function Item({
align === 'first-line' && styles.alignFirstLine,
isInteractive && styles.interactive,
isInteractive && interactionOverlayStyles.backgroundColor,
+ // The touch press on a compositor layer (after the overlay, whose
+ // own touch paint it turns off): the release keeps fading while
+ // script runs.
+ isInteractive && rowPressLayerStyles.cell,
isLinkRoot && styles.linkRoot,
isHighlighted && styles.highlighted,
isSelected && styles.selected,
diff --git a/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts
new file mode 100644
index 0000000000..5450adc88b
--- /dev/null
+++ b/packages/core/src/List/__tests__/ListRowPress.interaction.browser.spec.ts
@@ -0,0 +1,704 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file ListRowPress.interaction.browser.spec.ts
+ * @input The built List, TreeList and press feedback stories, real touch input
+ * (Chromium CDP / WebKit's input command), the interaction harness, and the
+ * cell release clock and curve from the UIKit constants table
+ * (motion/uikit/timing.ts)
+ * @output Interaction and animation proofs for a list row's touch press
+ * release: a held row paints the pressed token at full strength, and the
+ * release follows the cell release curve sampled frame by frame (both
+ * engines); the release keeps fading on every frame while the main thread
+ * is blocked (Chromium screencast, WebKit video); the release does no
+ * Layout or Paint; storyboards of the release and of the blocked window
+ * @position Interaction evidence for the row press layer
+ * (privateAttributes/press.stylex.ts `rowPressLayerStyles.cell`) as composed by Item
+ * (List rows) and TreeList rows
+ *
+ * The press strength is read from pixels: the row's own background before
+ * the press is strength 0, the frame the press is believed is strength 1, and
+ * every other frame is placed between the two. The pressed overlay is a
+ * translucent token, so the sampled channel moves linearly with the layer's
+ * opacity.
+ */
+
+import {readFile} from 'node:fs/promises';
+import {
+ chromium,
+ expect,
+ keepRequestsLocal,
+ test,
+ type Locator,
+ type Page,
+} from '@astryxdesign/a11y-spec/playwright';
+import {
+ animationStoryboard,
+ blockMainThread,
+ castStoryboard,
+ compareCurve,
+ countBetween,
+ cubicBezier,
+ freezeTimers,
+ holdAnimations,
+ installLongTaskLog,
+ installTimerGate,
+ openStory,
+ readLongTasks,
+ releaseAnimations,
+ seekAnimations,
+ startScreencast,
+ tap,
+ thawTimers,
+ timeline,
+ touchDriver,
+ traceRendering,
+ waitForAnimation,
+ withStorybook,
+ writeEvidence,
+ type CastFrame,
+ type TouchDriver,
+} from '@astryxdesign/interaction-harness';
+import {timing} from '../../motion/uikit/timing';
+
+const storybook = withStorybook(test);
+
+const RELEASE_MS = timing.press.highlightOutMs;
+const releaseEase = cubicBezier(...timing.press.highlightOutCurve);
+/** The layer's opacity t ms into the release: the strength, 1 → 0. */
+const expectedStrength = (t: number) =>
+ 1 - releaseEase(Math.min(1, Math.max(0, t / RELEASE_MS)));
+
+/** Long enough that the press is believed (scroll.delaysContentTouchesMs). */
+const HOLD_MS = 400;
+
+interface RowStory {
+ readonly name: string;
+ readonly story: string;
+ /** The pressable row under test. */
+ readonly row: (page: Page) => Locator;
+}
+
+const LIST_ROW: RowStory = {
+ name: 'List row',
+ story: 'core-list--interactive',
+ // "Sent": not the selected row, so its resting background is the page's.
+ row: page =>
+ page.locator('[data-astryx-pressable]').filter({hasText: 'Sent'}).first(),
+};
+
+const SCROLLER_ROW: RowStory = {
+ name: 'Item row in a scroller',
+ story: 'core-press-feedback-touch--rows',
+ row: page =>
+ page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Conversation 2'})
+ .first(),
+};
+
+const TREE_ROW: RowStory = {
+ name: 'TreeList row',
+ story: 'core-treelist--basic',
+ row: page =>
+ page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'App.tsx'})
+ .first(),
+};
+
+interface OpenRow {
+ driver: TouchDriver;
+ row: Locator;
+ /**
+ * A point inside the row's trailing padding, clear of its text, icons and
+ * (in a tree) the guide lines, CSS px.
+ */
+ probe: {x: number; y: number};
+ center: {x: number; y: number};
+}
+
+async function openRow(page: Page, story: RowStory): Promise<OpenRow> {
+ await installLongTaskLog(page);
+ await openStory(page, storybook(), story.story);
+ const driver = await touchDriver(page);
+ const row = story.row(page);
+ await expect(row).toBeVisible();
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error(`${story.name}: no row`);
+ }
+ return {
+ driver,
+ row,
+ probe: {
+ x: Math.round(box.x + box.width - 3),
+ y: Math.round(box.y + box.height / 2),
+ },
+ center: {x: box.x + box.width / 2, y: box.y + box.height / 2},
+ };
+}
+
+/** Opacity of the row's press layer (the `::before`), as the engine presents it. */
+/** The press layer's strength: 0 while the row has no layer box (at rest). */
+const layerOpacity = async (row: Locator) =>
+ row.evaluate(el => {
+ const before = getComputedStyle(el, '::before');
+ return before.content === 'none' || before.content === 'normal'
+ ? 0
+ : Number(before.opacity);
+ });
+
+/** The press attribute the controller writes on the row. */
+const pressState = async (row: Locator) =>
+ row.evaluate(el => el.getAttribute('data-astryx-press'));
+
+interface PixelFrame {
+ readonly t: number;
+ /** Mean of the RGB channels at the probe point, 0–255. */
+ readonly value: number;
+}
+
+/**
+ * The probe point's value in every frame. Decoding runs in a scratch page of
+ * the same browser (no image decoder in Node), like the harness's own marker
+ * tracking.
+ */
+async function samplePixel(
+ page: Page,
+ frames: ReadonlyArray<CastFrame>,
+ probe: {x: number; y: number},
+): Promise<PixelFrame[]> {
+ const scratch = await page.context().newPage();
+ try {
+ const out: PixelFrame[] = [];
+ for (let i = 0; i < frames.length; i += 12) {
+ const batch = frames.slice(i, i + 12);
+ const values = await scratch.evaluate(
+ async ({items, at}) => {
+ const results: number[] = [];
+ for (const item of items) {
+ const bitmap = await createImageBitmap(
+ await (
+ await fetch(`data:image/${item.format};base64,${item.data}`)
+ ).blob(),
+ );
+ const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
+ const context = canvas.getContext('2d');
+ if (context == null) {
+ throw new Error('no 2d context');
+ }
+ context.drawImage(bitmap, 0, 0);
+ const scale = bitmap.width / item.viewportWidth;
+ const px = context.getImageData(
+ Math.round(at.x * scale),
+ Math.round(at.y * scale),
+ 1,
+ 1,
+ ).data;
+ results.push((px[0] + px[1] + px[2]) / 3);
+ }
+ return results;
+ },
+ {
+ items: batch.map(f => ({
+ data: f.data,
+ format: f.format,
+ viewportWidth: f.viewportWidth,
+ })),
+ at: probe,
+ },
+ );
+ values.forEach((value, k) => out.push({t: batch[k].t, value}));
+ }
+ return out;
+ } finally {
+ await scratch.close();
+ }
+}
+
+test('a held row paints the pressed token and its release follows the cell release curve, sampled frame by frame', async ({
+ page,
+}, testInfo) => {
+ const {driver, row, center} = await openRow(page, LIST_ROW);
+ expect(await layerOpacity(row)).toBe(0);
+ // Gate the page's timers before the press, so the controller's check at
+ // the release clock (after which the release ends with its animation) can
+ // be held while the release is seeked.
+ await installTimerGate(page);
+ await driver.play(tap(center, {holdMs: HOLD_MS}));
+ expect(await pressState(row)).toBe('fading');
+ await freezeTimers(page);
+ const held = await holdAnimations(page, row);
+ const release = held.find(
+ a => a.target?.startsWith('li') && a.kind === 'CSSAnimation',
+ );
+ expect(release, JSON.stringify(held)).toBeDefined();
+ expect(release?.durationMs).toBe(RELEASE_MS);
+ const samples: {t: number; value: number}[] = [];
+ for (const t of timeline(RELEASE_MS)) {
+ await seekAnimations(page, t);
+ samples.push({t, value: await layerOpacity(row)});
+ }
+ await releaseAnimations(page, {finish: true});
+ await thawTimers(page);
+ const comparison = compareCurve(samples, expectedStrength, 0.005);
+ await writeEvidence(
+ 'curves/list-row-press-release',
+ {
+ [`${testInfo.project.name}.json`]: JSON.stringify(
+ {
+ releaseMs: RELEASE_MS,
+ curve: timing.press.highlightOutCurve,
+ held,
+ samples,
+ comparison,
+ },
+ null,
+ 2,
+ ),
+ },
+ testInfo,
+ );
+ expect(samples[0].value).toBeCloseTo(1, 2);
+ expect(
+ comparison.maxError,
+ JSON.stringify(comparison.worst),
+ ).toBeLessThanOrEqual(0.005);
+ // At rest after the release: no press, no layer.
+ await expect.poll(async () => pressState(row)).toBeNull();
+ expect(await layerOpacity(row)).toBe(0);
+});
+
+for (const story of [LIST_ROW, SCROLLER_ROW, TREE_ROW]) {
+ test(`${story.name}: the release keeps fading on every frame while the main thread is blocked`, async ({
+ page,
+ browserName,
+ }, testInfo) => {
+ test.skip(
+ browserName !== 'chromium',
+ 'screencast frame evidence is Chromium-only in Playwright; WebKit has its own video proof below',
+ );
+ const {driver, row, center, probe} = await openRow(page, story);
+ const cast = await startScreencast(page);
+ // Strength 0 is the row at rest; strength 1 the believed press.
+ await driver.play(tap(center, {holdMs: HOLD_MS}));
+ const [release] = await waitForAnimation(row, {minProgressMs: 16});
+ const block = await blockMainThread(page, 700);
+ await page.waitForTimeout(150);
+ const frames = await cast.stop();
+ const pixels = await samplePixel(page, frames, probe);
+ const rest = pixels[0].value;
+ const pressedFrames = pixels.filter(p => p.t < release.from);
+ const pressed = Math.min(...pressedFrames.map(p => p.value));
+ const strength = (v: number) => (rest - v) / (rest - pressed);
+ // Judge the release while it was still visibly moving inside the block.
+ const end = Math.min(block.to, release.to) - 10;
+ const during = pixels.filter(p => p.t > block.from && p.t <= end);
+ const strengths = during.map(p => ({
+ t: +(p.t - block.from).toFixed(1),
+ strength: +strength(p.value).toFixed(3),
+ }));
+ const intervals = during
+ .map((p, i) => (i === 0 ? p.t - block.from : p.t - during[i - 1].t))
+ .filter(dt => dt > 0);
+ const longestGap = Math.max(
+ end - (during.at(-1)?.t ?? block.from),
+ ...intervals,
+ );
+ await writeEvidence(
+ `busy-main-thread/${story.story}`,
+ {
+ [`${testInfo.project.name}.json`]: JSON.stringify(
+ {block, release, rest, pressed, strengths},
+ null,
+ 1,
+ ),
+ },
+ testInfo,
+ );
+ const film = await castStoryboard(page, frames, {
+ name: `${story.story}-release-busy-main-thread`,
+ zero: block.from,
+ from: release.from - 40,
+ to: release.to + 40,
+ columns: 6,
+ cellScale: 0.45,
+ data: t => {
+ const p = pixels.find(f => f.t === t);
+ return {strength: p == null ? -1 : +strength(p.value).toFixed(3)};
+ },
+ });
+ await film.write(testInfo, {block, release});
+ // The press painted at full strength before the lift.
+ expect(rest - pressed).toBeGreaterThan(10);
+ // Frames kept coming through the block, each one further along the fade.
+ expect(during.length, JSON.stringify(strengths)).toBeGreaterThanOrEqual(
+ Math.floor((end - block.from) / (1000 / 60)) - 2,
+ );
+ expect(longestGap).toBeLessThan(40);
+ for (let i = 1; i < strengths.length; i++) {
+ expect(strengths[i].strength).toBeLessThanOrEqual(
+ strengths[i - 1].strength + 0.01,
+ );
+ }
+ const last = strengths.at(-1);
+ expect(last).toBeDefined();
+ expect(strengths[0].strength).toBeGreaterThan((last?.strength ?? 1) + 0.2);
+ });
+}
+
+test('a busy first frame after the lift delays the release instead of skipping into it', async ({
+ page,
+ browserName,
+}) => {
+ test.skip(
+ browserName === 'webkit',
+ 'WebKit starts the release at the time the busy script began, so the first frame after a 150 ms block reads opacity 0.03; the next case shows the release still plays to its end there',
+ );
+ const {driver, row, center} = await openRow(page, LIST_ROW);
+ // When the press controller writes the release, 150 ms of script hold the
+ // main thread before the first frame. The release starts when the browser
+ // styles it, so the first frame due after the block shows it at most one
+ // frame in.
+ await row.evaluate(el => {
+ (window as unknown as {__first: Promise<number>}).__first = new Promise(
+ resolve => {
+ const observer = new MutationObserver(() => {
+ if (el.getAttribute('data-astryx-press') !== 'fading') {
+ return;
+ }
+ observer.disconnect();
+ const until = performance.now() + 150;
+ while (performance.now() < until) {
+ // Busy: the main thread is held.
+ }
+ // The first frame due after the block: a frame scheduled before
+ // it runs with that earlier time.
+ const read = () => {
+ if ((document.timeline.currentTime as number) < until) {
+ requestAnimationFrame(read);
+ return;
+ }
+ resolve(Number(getComputedStyle(el, '::before').opacity));
+ };
+ requestAnimationFrame(read);
+ });
+ observer.observe(el, {attributeFilter: ['data-astryx-press']});
+ },
+ );
+ });
+ await driver.play(tap(center, {holdMs: 300}));
+ const first = await page.evaluate(
+ async () => (window as unknown as {__first: Promise<number>}).__first,
+ );
+ // At most one frame into the release: its ease-out curve takes the first
+ // frame to about 0.74; a start pinned before the block would be past 0.4.
+ expect(first).toBeGreaterThan(0.7);
+ await expect.poll(async () => layerOpacity(row)).toBe(0);
+});
+
+test('a busy first frame after the lift still plays the whole release before the press attribute goes', async ({
+ page,
+ browserName,
+}) => {
+ const {driver, row, center} = await openRow(page, LIST_ROW);
+ // When the press controller writes the release, 150 ms of script hold the
+ // main thread before the first frame, so the release starts after the
+ // block. Every frame after it is read until the attribute goes: the layer
+ // must reach rest on the curve, not vanish while it is still painted.
+ await row.evaluate(el => {
+ const frames: [number, number, string | null][] = [];
+ (window as unknown as {__frames: typeof frames}).__frames = frames;
+ const observer = new MutationObserver(() => {
+ if (el.getAttribute('data-astryx-press') !== 'fading') {
+ return;
+ }
+ observer.disconnect();
+ const until = performance.now() + 150;
+ while (performance.now() < until) {
+ // Busy: the main thread is held.
+ }
+ const sample = (time: number) => {
+ const layer = getComputedStyle(el, '::before');
+ const strength =
+ layer.content === 'none' || layer.content === 'normal'
+ ? 0
+ : Number(layer.opacity);
+ const press = el.getAttribute('data-astryx-press');
+ if ((document.timeline.currentTime as number) >= until) {
+ frames.push([+(time - until).toFixed(1), strength, press]);
+ }
+ if (press === 'fading' && frames.length < 120) {
+ requestAnimationFrame(sample);
+ }
+ };
+ requestAnimationFrame(sample);
+ });
+ observer.observe(el, {attributeFilter: ['data-astryx-press']});
+ });
+ await driver.play(tap(center, {holdMs: 300}));
+ await expect.poll(async () => pressState(row)).toBeNull();
+ const frames = await page.evaluate(
+ () =>
+ (window as unknown as {__frames: [number, number, string | null][]})
+ .__frames,
+ );
+ const fading = frames.filter(([, , press]) => press === 'fading');
+ // WebKit can start the release at the time the busy script began, so its
+ // first frame after the block can already be near rest (opacity 0.03
+ // measured) and few frames remain. There, only the end and the order of
+ // the frames hold.
+ if (browserName !== 'webkit') {
+ expect(fading.length, JSON.stringify(frames)).toBeGreaterThan(3);
+ }
+ // The last frame still fading is at rest or within one frame of it: the
+ // attribute goes once the release has played, however late it started.
+ expect(fading.at(-1)?.[1], JSON.stringify(frames)).toBeLessThanOrEqual(0.05);
+ // And the release played on the way there, frame by frame.
+ for (let i = 1; i < fading.length; i++) {
+ expect(fading[i][1], JSON.stringify(frames)).toBeLessThanOrEqual(
+ fading[i - 1][1] + 0.01,
+ );
+ }
+});
+
+test('the release does no Layout or Paint per frame', async ({
+ page,
+ browserName,
+}) => {
+ test.skip(browserName !== 'chromium', 'rendering traces are Chromium-only');
+ const {driver, row, center} = await openRow(page, LIST_ROW);
+ let release = {from: 0, to: 0};
+ const started = Date.now();
+ const trace = await traceRendering(page, async () => {
+ await driver.play(tap(center, {holdMs: HOLD_MS}));
+ [release] = await waitForAnimation(row);
+ await page.waitForTimeout(RELEASE_MS + 100);
+ });
+ // The steady part of the release: its first and last frames may commit.
+ const during = countBetween(trace, release.from + 30, release.to - 30);
+ expect(during.Layout ?? 0, JSON.stringify(during)).toBe(0);
+ expect(during.Paint ?? 0, JSON.stringify(during)).toBe(0);
+ expect(await readLongTasks(page, {from: started, to: Date.now()})).toEqual(
+ [],
+ );
+});
+
+test('WebKit: the release keeps fading while the main thread is blocked (video)', async ({
+ browser,
+ browserName,
+}, testInfo) => {
+ test.skip(
+ browserName !== 'webkit',
+ 'the Chromium screencast test covers Chromium',
+ );
+ const size = {width: 402, height: 714};
+ const context = await browser.newContext({
+ viewport: size,
+ deviceScaleFactor: 1,
+ isMobile: true,
+ hasTouch: true,
+ recordVideo: {dir: testInfo.outputPath('video'), size},
+ });
+ const page = await context.newPage();
+ const {driver, center, probe} = await openRow(page, LIST_ROW);
+ // A beacon the main thread paints: blue while it is about to block, green
+ // once it has run again. Frames in which the beacon is blue were presented
+ // while script could not run.
+ await page.evaluate(() => {
+ const beacon = document.createElement('div');
+ beacon.id = 'beacon';
+ Object.assign(beacon.style, {
+ position: 'fixed',
+ right: '0',
+ bottom: '0',
+ width: '40px',
+ height: '40px',
+ background: 'rgb(128, 128, 128)',
+ zIndex: '2147483647',
+ });
+ document.body.append(beacon);
+ });
+ // Armed in the page so the block starts two frames after the lift, with
+ // no test-runner round trip in between: blue, committed by two frames,
+ // then the block; every frame showing blue was presented while script
+ // could not run.
+ await page.evaluate(() => {
+ addEventListener(
+ 'touchend',
+ () => {
+ const beacon = document.getElementById('beacon') as HTMLElement;
+ beacon.style.background = 'rgb(0, 0, 255)';
+ requestAnimationFrame(() =>
+ requestAnimationFrame(() => {
+ const end = performance.now() + 700;
+ while (performance.now() < end) {
+ // blocked
+ }
+ beacon.style.background = 'rgb(0, 200, 0)';
+ }),
+ );
+ },
+ {once: true, passive: true, capture: true},
+ );
+ });
+ await page.waitForTimeout(300);
+ await driver.play(tap(center, {holdMs: HOLD_MS}));
+ await page.waitForTimeout(1300);
+ const video = page.video();
+ await context.close();
+ const path = await video?.path();
+ expect(path).toBeTruthy();
+ const bytes = (await readFile(path as string)).toString('base64');
+ const decoder = await chromium.launch();
+ try {
+ const playerContext = await decoder.newContext();
+ await keepRequestsLocal(playerContext);
+ const player = await playerContext.newPage();
+ const samples = await player.evaluate(
+ async ({at, webm, beaconAt}) => {
+ const element = document.createElement('video');
+ element.muted = true;
+ element.src = URL.createObjectURL(
+ new Blob([Uint8Array.from(atob(webm), c => c.charCodeAt(0))], {
+ type: 'video/webm',
+ }),
+ );
+ document.body.append(element);
+ if (element.readyState < 1) {
+ await new Promise(r =>
+ element.addEventListener('loadedmetadata', r, {once: true}),
+ );
+ }
+ element.pause();
+ const canvas = document.createElement('canvas');
+ canvas.width = element.videoWidth;
+ canvas.height = element.videoHeight;
+ const context2d = canvas.getContext('2d', {
+ willReadFrequently: true,
+ }) as CanvasRenderingContext2D;
+ const out: {t: number; value: number; beacon: string}[] = [];
+ const duration = Number.isFinite(element.duration)
+ ? element.duration
+ : 10;
+ for (let t = 0; t < duration; t += 0.01) {
+ element.currentTime = t;
+ await new Promise(r =>
+ element.addEventListener('seeked', r, {once: true}),
+ );
+ context2d.drawImage(element, 0, 0);
+ const px = context2d.getImageData(at.x, at.y, 1, 1).data;
+ const b = context2d.getImageData(beaconAt.x, beaconAt.y, 1, 1).data;
+ const beacon =
+ b[2] > 180 && b[0] < 80
+ ? 'blocked'
+ : b[1] > 150 && b[2] < 80
+ ? 'after'
+ : 'before';
+ out.push({t, value: (px[0] + px[1] + px[2]) / 3, beacon});
+ }
+ return out;
+ },
+ {
+ at: probe,
+ webm: bytes,
+ beaconAt: {x: size.width - 20, y: size.height - 20},
+ },
+ );
+ const blocked = samples.filter(s => s.beacon === 'blocked');
+ const rest = Math.max(
+ ...samples.filter(s => s.beacon === 'before').map(s => s.value),
+ );
+ // Judge the release up to the frame it reaches the row's resting color.
+ // (Measured in the Linux WebKit build: once an accelerated animation has
+ // finished while script is still blocked, the compositor shows the value
+ // the main thread last committed until script runs again. That is this
+ // build's end-of-animation hand-back, after the release; iOS Safari 26.2
+ // holds the resting color on the simulator. It is recorded below, not
+ // judged here.)
+ const restIndex = blocked.findIndex(s => s.value >= rest - 1);
+ const fading = restIndex === -1 ? blocked : blocked.slice(0, restIndex + 1);
+ const distinct = fading
+ .map(s => Math.round(s.value))
+ .filter((v, i, all) => i === 0 || v !== all[i - 1]);
+ const afterEnd = restIndex === -1 ? [] : blocked.slice(restIndex + 1);
+ await writeEvidence(
+ 'busy-main-thread/list-row-release-webkit',
+ {
+ 'webkit.json': JSON.stringify(
+ {rest, blocked, distinct, afterEnd},
+ null,
+ 1,
+ ),
+ },
+ testInfo,
+ );
+ testInfo.annotations.push({
+ type: 'WebKit frames during the block',
+ description: `release: ${distinct.join(' ')}; after it ended, still blocked: ${[
+ ...new Set(afterEnd.map(s => Math.round(s.value))),
+ ].join(' ')}`,
+ });
+ expect(blocked.length).toBeGreaterThan(0);
+ // The row kept getting lighter while script could not run, all the way
+ // to its resting color: from a frame still short of rest, it reached rest
+ // inside the blocked window. A release on the main thread would hold its
+ // first frame's value until the block ends, 700 ms on, and could not. (The
+ // recording's frames are 40 ms apart, so how many land inside the 200 ms
+ // release depends on its phase: the count is not judged.)
+ const values = JSON.stringify(blocked.map(s => Math.round(s.value)));
+ expect(blocked[0].value, values).toBeLessThan(rest - 1);
+ expect(restIndex, values).toBeGreaterThan(0);
+ for (let i = 1; i < distinct.length; i++) {
+ expect(distinct[i], values).toBeGreaterThan(distinct[i - 1]);
+ }
+ } finally {
+ await decoder.close();
+ }
+});
+
+test(
+ 'storyboard: a row released after a hold',
+ {tag: '@storyboard'},
+ async ({page}, testInfo) => {
+ const {driver, row, center} = await openRow(page, LIST_ROW);
+ await installTimerGate(page);
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ const clip = {
+ x: 0,
+ y: Math.max(0, box.y - 16),
+ width: page.viewportSize()?.width ?? 402,
+ height: box.height + 32,
+ };
+ await driver.play(tap(center, {holdMs: HOLD_MS}));
+ await freezeTimers(page);
+ const {storyboard} = await animationStoryboard(page, {
+ name: 'list-row-press-release',
+ clip,
+ scope: row,
+ measure: async () => ({
+ opacity: await layerOpacity(row),
+ state: await pressState(row),
+ }),
+ columns: 7,
+ cellScale: 0.6,
+ });
+ await releaseAnimations(page, {finish: true});
+ await thawTimers(page);
+ await storyboard.write(testInfo);
+ // The trace is the assertion; the sheet is the evidence.
+ const opacities = storyboard.frames.map(f => f.data.opacity as number);
+ expect(opacities[0]).toBeCloseTo(1, 2);
+ expect(opacities.at(-1)).toBeLessThan(0.01);
+ for (let i = 1; i < opacities.length; i++) {
+ expect(opacities[i]).toBeLessThanOrEqual(opacities[i - 1] + 1e-6);
+ }
+ storyboard.frames.forEach(f =>
+ expect(f.data.opacity as number).toBeCloseTo(expectedStrength(f.t), 2),
+ );
+ },
+);
diff --git a/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts
new file mode 100644
index 0000000000..4ccf0420b9
--- /dev/null
+++ b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts
@@ -0,0 +1,481 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file ListRowPressPaths.interaction.browser.spec.ts
+ * @input The built List "Interactive" and Press Feedback "Rows" stories, the
+ * interaction harness, and the cell release clock (motion/uikit/timing.ts)
+ * @output The row press paths beside the main release proofs: a press the
+ * browser takes for a scroll drops the highlight at once (the press
+ * controller's cancel, unchanged by the compositor layer); Reduce
+ * Motion keeps the fade (a fade, not a movement); a mouse press and hover on
+ * a fine pointer leave the press layer out of it; a row held and released
+ * between two divided rows keeps both dividers drawn (`component:List`
+ * FR11), by pixels and by computed border
+ * @position Interaction evidence for the row press layer
+ * (privateAttributes/press.stylex.ts `rowPressLayerStyles.cell`), beside
+ * ListRowPress.interaction.browser.spec.ts
+ */
+
+import {
+ expect,
+ test,
+ type Locator,
+ type Page,
+} from '@astryxdesign/a11y-spec/playwright';
+import {
+ drag,
+ holdAnimations,
+ openStory,
+ releaseAnimations,
+ seekAnimations,
+ tap,
+ touchDriver,
+ withStorybook,
+} from '@astryxdesign/interaction-harness';
+// @ts-expect-error -- pngjs ships no declarations; runtime support is pinned.
+import {PNG} from 'pngjs';
+import {timing} from '../../motion/uikit/timing';
+
+const storybook = withStorybook(test);
+
+const RELEASE_MS: number = timing.press.highlightOutMs;
+
+/** The press layer's strength: 0 while the row has no layer box (at rest). */
+const layerOpacity = async (row: Locator) =>
+ row.evaluate(el => {
+ const before = getComputedStyle(el, '::before');
+ return before.content === 'none' || before.content === 'normal'
+ ? 0
+ : Number(before.opacity);
+ });
+
+const pressState = async (row: Locator) =>
+ row.evaluate(el => el.getAttribute('data-astryx-press'));
+
+/**
+ * A row's bottom divider: its computed border and the pixels of the strip it
+ * draws across the row (inset from the rounded ends), decoded.
+ */
+async function dividerOf(page: Page, row: Locator) {
+ const border = await row.evaluate(el => {
+ const style = getComputedStyle(el);
+ return {
+ width: Number.parseFloat(style.borderBottomWidth),
+ style: style.borderBottomStyle,
+ color: style.borderBottomColor,
+ };
+ });
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ const strip = async (top: number) =>
+ page.screenshot({
+ clip: {x: box.x + 12, y: top, width: box.width - 24, height: 1},
+ });
+ const pixels = PNG.sync.read(
+ await strip(box.y + box.height - border.width),
+ ) as {width: number; height: number; data: Uint8Array};
+ const inside = PNG.sync.read(
+ await strip(box.y + box.height - border.width - 4),
+ ) as {data: Uint8Array};
+ return {border, pixels: pixels.data, inside: inside.data};
+}
+
+/** The largest channel difference between two decoded strips. */
+function largestDifference(a: Uint8Array, b: Uint8Array): number {
+ let largest = a.length === b.length ? 0 : 255;
+ for (let i = 0; i < Math.min(a.length, b.length); i++) {
+ largest = Math.max(largest, Math.abs(a[i] - b[i]));
+ }
+ return largest;
+}
+
+async function touchOnly(page: Page) {
+ const touch = await page.evaluate(
+ () => matchMedia('(pointer: coarse)').matches,
+ );
+ test.skip(!touch, 'the press layer serves a touch screen');
+}
+
+test("a press the browser takes for a scroll drops the highlight at once (the controller's cancel, unchanged)", async ({
+ page,
+}) => {
+ await openStory(page, storybook(), 'core-press-feedback-touch--rows');
+ await touchOnly(page);
+ const driver = await touchDriver(page);
+ const row = page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Conversation 2'})
+ .first();
+ await expect(row).toBeVisible();
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ // Every press state the controller writes, and every animation the row's
+ // layer starts, with page times.
+ await row.evaluate(el => {
+ const log: string[] = [];
+ (window as unknown as {__pressLog: string[]}).__pressLog = log;
+ new MutationObserver(() =>
+ log.push(`press:${el.getAttribute('data-astryx-press')}`),
+ ).observe(el, {attributeFilter: ['data-astryx-press']});
+ el.addEventListener('animationstart', event =>
+ log.push(`start:${(event as AnimationEvent).pseudoElement}`),
+ );
+ });
+ const from = {x: box.x + box.width / 2, y: box.y + box.height / 2};
+ // Held long enough for the highlight to show, then a vertical pan the
+ // scroller takes: the browser cancels the touch for the page.
+ await driver.play(
+ drag(from, {x: from.x, y: from.y - 80}, {holdMs: 300, durationMs: 160}),
+ );
+ await expect.poll(async () => pressState(row)).toBeNull();
+ const log = await page.evaluate(
+ () => (window as unknown as {__pressLog: string[]}).__pressLog,
+ );
+ // Highlighted while held, then the scroll's cancel removes it outright:
+ // no release fade starts, and the row is at rest.
+ expect(log, JSON.stringify(log)).toContain('press:on');
+ expect(log.at(-1), JSON.stringify(log)).toBe('press:null');
+ expect(log, JSON.stringify(log)).not.toContain('press:fading');
+ expect(log, JSON.stringify(log)).not.toContain('start:::before');
+ expect(await layerOpacity(row)).toBe(0);
+});
+
+test('Reduce Motion keeps the release fade: a fade, not a movement', async ({
+ page,
+}) => {
+ await page.emulateMedia({reducedMotion: 'reduce'});
+ await openStory(page, storybook(), 'core-list--interactive');
+ await touchOnly(page);
+ const driver = await touchDriver(page);
+ const row = page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Sent'})
+ .first();
+ await expect(row).toBeVisible();
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ await driver.play(
+ tap({x: box.x + box.width / 2, y: box.y + box.height / 2}, {holdMs: 300}),
+ );
+ await holdAnimations(page);
+ await seekAnimations(page, 0);
+ expect(await layerOpacity(row)).toBeCloseTo(1, 2);
+ await seekAnimations(page, RELEASE_MS / 2);
+ const midway = await layerOpacity(row);
+ expect(midway).toBeGreaterThan(0.05);
+ expect(midway).toBeLessThan(0.95);
+ await releaseAnimations(page, {finish: true});
+ await expect.poll(async () => layerOpacity(row)).toBe(0);
+});
+
+test('under a finger, a row held and released between two divided rows keeps both dividers drawn, by pixels and computed border (component:List FR11)', async ({
+ page,
+}) => {
+ await openStory(page, storybook(), 'core-list--interactive', {
+ hasDividers: '!true',
+ });
+ await touchOnly(page);
+ const driver = await touchDriver(page);
+ const row = (label: string) =>
+ page.locator('[data-astryx-pressable]').filter({hasText: label}).first();
+ const above = row('Inbox');
+ const pressed = row('Sent');
+ await expect(pressed).toBeVisible();
+ // At rest: both dividers drawn, and their strips differ from the row's
+ // own surface just inside them, so a strip that matches later is a drawn
+ // divider, not a blank.
+ const atRest = {
+ above: await dividerOf(page, above),
+ pressed: await dividerOf(page, pressed),
+ };
+ for (const divider of Object.values(atRest)) {
+ expect(divider.border.width).toBeGreaterThan(0);
+ expect(divider.border.style).toBe('solid');
+ expect(divider.border.color).not.toMatch(/^rgba\(.*,\s*0\)$/);
+ expect(largestDifference(divider.pixels, divider.inside)).toBeGreaterThan(
+ 8,
+ );
+ }
+ /** Each divider as it is at rest, by computed border and by pixels. */
+ const expectDividersAsAtRest = async (phase: string) => {
+ for (const [name, target] of [
+ ['above', above],
+ ['pressed', pressed],
+ ] as const) {
+ const now = await dividerOf(page, target);
+ expect(now.border, `${phase}: ${name}`).toEqual(atRest[name].border);
+ expect(
+ largestDifference(now.pixels, atRest[name].pixels),
+ `${phase}: ${name}'s divider pixels`,
+ ).toBeLessThanOrEqual(8);
+ }
+ };
+ const box = await pressed.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ // Held: checked while the finger is still down, after the first event.
+ await driver.play(
+ tap({x: box.x + box.width / 2, y: box.y + box.height / 2}, {holdMs: 600}),
+ {
+ onEvent: async (_step, index) => {
+ if (index !== 0) {
+ return;
+ }
+ await expect.poll(async () => pressState(pressed)).toBe('on');
+ await expectDividersAsAtRest('held');
+ },
+ },
+ );
+ // Released: halfway through the release fade.
+ await holdAnimations(page);
+ await seekAnimations(page, RELEASE_MS / 2);
+ expect(await pressState(pressed)).toBe('fading');
+ await expectDividersAsAtRest('releasing');
+ await releaseAnimations(page, {finish: true});
+ await expect.poll(async () => pressState(pressed)).toBeNull();
+ await expectDividersAsAtRest('after the release');
+});
+
+test('a mouse press and hover on a fine pointer leave the press layer out of it', async ({
+ browser,
+}) => {
+ const context = await browser.newContext({
+ viewport: {width: 1024, height: 768},
+ hasTouch: false,
+ isMobile: false,
+ });
+ const page = await context.newPage();
+ try {
+ await openStory(page, storybook(), 'core-list--interactive');
+ expect(
+ await page.evaluate(() => matchMedia('(pointer: coarse)').matches),
+ ).toBe(false);
+ const fine = await page.evaluate(
+ () => matchMedia('(pointer: fine)').matches,
+ );
+ expect(fine).toBe(true);
+ const row = page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Sent'})
+ .first();
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ // No layer at all with a fine pointer: hovering, pressing and lifting
+ // never give the row a `::before` box.
+ const layer = async () =>
+ row.evaluate(el => getComputedStyle(el, '::before').content);
+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ expect(await layer()).toBe('none');
+ await page.mouse.down();
+ expect(await pressState(row)).toBeNull();
+ expect(await layer()).toBe('none');
+ await page.mouse.up();
+ expect(await pressState(row)).toBeNull();
+ expect(await layer()).toBe('none');
+ } finally {
+ await context.close();
+ }
+});
+
+test('a fine pointer: a row is as it was, with no press layer and no stacking context (desktop unchanged)', async ({
+ browser,
+}) => {
+ // AST-017 FR59/DEC-25: touch work leaves a fine pointer's rows as they were. The
+ // press layer and the stacking context it needs exist under a finger only,
+ // so a caller's own `::before` and z-index behave as before.
+ const context = await browser.newContext({
+ viewport: {width: 1024, height: 768},
+ hasTouch: false,
+ isMobile: false,
+ });
+ const page = await context.newPage();
+ try {
+ const rowBox = async (story: string, selector: string, label: string) => {
+ await openStory(page, storybook(), story);
+ expect(
+ await page.evaluate(() => matchMedia('(pointer: coarse)').matches),
+ ).toBe(false);
+ const row = page.locator(selector).filter({hasText: label}).first();
+ await expect(row).toBeVisible();
+ return row.evaluate(el => ({
+ before: getComputedStyle(el, '::before').content,
+ isolation: getComputedStyle(el).isolation,
+ }));
+ };
+ expect(
+ await rowBox('core-list--interactive', '[data-astryx-pressable]', 'Sent'),
+ ).toEqual({before: 'none', isolation: 'auto'});
+ // A row's own `::before` is exactly as its author wrote it: nothing of
+ // the layer (its opacity, stacking, hit testing) reaches it.
+ const own = await page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Sent'})
+ .first()
+ .evaluate(el => {
+ const style = document.createElement('style');
+ style.textContent =
+ '[data-test-own]::before{content:"•";position:static;opacity:1}';
+ document.head.append(style);
+ el.setAttribute('data-test-own', '');
+ const before = getComputedStyle(el, '::before');
+ return {
+ content: before.content,
+ opacity: before.opacity,
+ position: before.position,
+ zIndex: before.zIndex,
+ pointerEvents: before.pointerEvents,
+ };
+ });
+ expect(own).toEqual({
+ content: '"•"',
+ opacity: '1',
+ position: 'static',
+ zIndex: 'auto',
+ pointerEvents: 'auto',
+ });
+ expect(
+ await rowBox(
+ 'core-treelist--interactive',
+ '#storybook-root [role="treeitem"] [data-astryx-pressable]',
+ 'Settings',
+ ),
+ ).toEqual({before: 'none', isolation: 'auto'});
+ } finally {
+ await context.close();
+ }
+});
+
+test('a radio row under a finger paints its circle’s press, and keeps its bare look: no row layer', async ({
+ page,
+ browserName,
+}) => {
+ test.skip(
+ browserName !== 'chromium',
+ 'the held touch is driven with Chromium touch events (CDP)',
+ );
+ await openStory(page, storybook(), 'core-radiolist--default');
+ await touchOnly(page);
+ const row = page.locator('#storybook-root [data-astryx-pressable]').first();
+ await expect(row).toBeVisible();
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ // On the label, away from the circle: the row takes the press.
+ const cdp = await page.context().newCDPSession(page);
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchStart',
+ touchPoints: [{x: box.x + box.width * 0.6, y: box.y + box.height / 2}],
+ });
+ await expect.poll(async () => pressState(row)).toBe('on');
+ const look = await row.evaluate(el => {
+ const wrapper = [...el.querySelectorAll('*')].find(
+ child =>
+ child.querySelector(':scope > input[type="radio"]') != null &&
+ getComputedStyle(child, '::after').content !== 'none',
+ );
+ return {
+ circle:
+ wrapper == null
+ ? null
+ : getComputedStyle(wrapper, '::after').backgroundImage,
+ layer: getComputedStyle(el, '::before').content,
+ isolation: getComputedStyle(el).isolation,
+ };
+ });
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchCancel',
+ touchPoints: [],
+ });
+ // The circle's own press paint: the pressed token, not a transparent
+ // gradient.
+ expect(look.circle).toMatch(/gradient/);
+ expect(look.circle).not.toMatch(
+ /^linear-gradient\(rgba\(0, 0, 0, 0\), rgba\(0, 0, 0, 0\)\)$/,
+ );
+ // Only the circle paints, as with a mouse: the row has no layer and is no
+ // stacking context.
+ expect(look.layer).toBe('none');
+ expect(look.isolation).toBe('auto');
+});
+
+test('under a finger, a row at rest is as it was: its own ::before keeps its look and it is no stacking context; the press layer takes the ::before only while pressed', async ({
+ page,
+ browserName,
+}) => {
+ test.skip(
+ browserName !== 'chromium',
+ 'the held touch is driven with Chromium touch events (CDP)',
+ );
+ await openStory(page, storybook(), 'core-list--interactive');
+ await touchOnly(page);
+ const row = page
+ .locator('[data-astryx-pressable]')
+ .filter({hasText: 'Sent'})
+ .first();
+ await expect(row).toBeVisible();
+ const look = async () =>
+ row.evaluate(el => {
+ const before = getComputedStyle(el, '::before');
+ return {
+ content: before.content,
+ opacity: before.opacity,
+ position: before.position,
+ zIndex: before.zIndex,
+ pointerEvents: before.pointerEvents,
+ isolation: getComputedStyle(el).isolation,
+ };
+ });
+ // A caller's own decoration on the row's `::before` (a page rule beats
+ // the components' layered styles for what it sets; the rest is theirs).
+ await row.evaluate(el => {
+ const style = document.createElement('style');
+ style.textContent = '[data-test-own]::before{content:"•"}';
+ document.head.append(style);
+ el.setAttribute('data-test-own', '');
+ });
+ const own = {
+ content: '"•"',
+ opacity: '1',
+ position: 'static',
+ zIndex: 'auto',
+ pointerEvents: 'auto',
+ isolation: 'auto',
+ };
+ expect(await look()).toEqual(own);
+ // A press: the layer takes the `::before`, in its own stacking context.
+ const box = await row.boundingBox();
+ if (box == null) {
+ throw new Error('no row');
+ }
+ const cdp = await page.context().newCDPSession(page);
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchStart',
+ touchPoints: [{x: box.x + box.width / 2, y: box.y + box.height / 2}],
+ });
+ await expect.poll(async () => pressState(row)).toBe('on');
+ // The layer's box (with the caller's content), painted, in its own
+ // stacking context.
+ const pressed = await look();
+ expect(pressed.content).toBe('"•"');
+ expect(pressed.position).toBe('absolute');
+ expect(pressed.zIndex).toBe('-1');
+ expect(pressed.opacity).toBe('1');
+ expect(pressed.isolation).toBe('isolate');
+ await cdp.send('Input.dispatchTouchEvent', {
+ type: 'touchCancel',
+ touchPoints: [],
+ });
+ // The press over, the row's own decoration is back as it was.
+ await expect.poll(async () => pressState(row)).toBeNull();
+ expect(await look()).toEqual(own);
+});
diff --git a/packages/core/src/RadioList/RadioListItem.tsx b/packages/core/src/RadioList/RadioListItem.tsx
index 64e64b09f1..6b22daceee 100644
--- a/packages/core/src/RadioList/RadioListItem.tsx
+++ b/packages/core/src/RadioList/RadioListItem.tsx
@@ -35,6 +35,7 @@ import {usePressFeedback} from '../hooks/usePressFeedback';
import {useIndicator} from '../Indicator/useIndicator';
import {Item, type ItemAlign} from '../Item/Item';
import {themeProps} from '../utils/themeProps';
+import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
// The touch press's paint, declared by the shared overlay styles on the
// element the controller writes to (`pressedAlpha`) at the press's strength,
@@ -147,11 +148,6 @@ const rowStyles = stylex.create({
// Suppress Item's interactive hover/press background so the resting and
// hovered row look identical by default (a theme can restyle either).
backgroundColor: 'transparent',
- // ...and the touch press's overlay image, for the same reason: under a
- // finger only the radio circle paints, as under a mouse. The press's
- // strength still lands on the row, which is where the layer over the
- // circle reads it.
- backgroundImage: 'none',
},
// The mouse press (a finger's lives on `data-astryx-press`): the row is
// pressed, but not through a nested link or button, which keep their own
@@ -414,6 +410,9 @@ export function RadioListItem({
// the painting row element (Item), the same element that carries the
// theme target, so a theme's hover styling stays in step with the tint.
!isDisabled && indicatorScope,
+ // The row keeps no press paint of its own: the circle paints, and
+ // reads the strength whose release the row keeps.
+ rowPressLayerStyles.cellWithoutLayer,
// Restore the bare default look: zero Item's padding/radius and its
// interactive hover/press background. Applied after Item's own base
// styles so it wins within the base layer; a `radio-list-item` theme
diff --git a/packages/core/src/TreeList/TreeListItem.tsx b/packages/core/src/TreeList/TreeListItem.tsx
index 62b60b4f53..4ae5429ff7 100644
--- a/packages/core/src/TreeList/TreeListItem.tsx
+++ b/packages/core/src/TreeList/TreeListItem.tsx
@@ -4,7 +4,8 @@
/**
* @file TreeListItem.tsx
- * @input Uses React, StyleX, theme tokens, TreeListBranches
+ * @input Uses React, StyleX, theme tokens, TreeListBranches, the shared press
+ * overlays and the compositor press layer
* @output Exports TreeListItem component (internal, not publicly exported)
* @position Internal implementation; consumed by TreeList.tsx
*
@@ -27,6 +28,7 @@ import {
} from '../theme/tokens.stylex';
import {focusOutlineProps} from '../utils/focusOutline.stylex';
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
+import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
import {usePressFeedback} from '../hooks/usePressFeedback';
import {
hasInteractiveAncestor,
@@ -713,6 +715,10 @@ export function TreeListItem({
densityStyles[density],
styles.interactive,
interactionOverlayStyles.backgroundImage,
+ // The touch press on a compositor layer (after the
+ // overlay, whose own touch paint it turns off).
+ rowPressLayerStyles.cell,
+ rowPressLayerStyles.cellOnImage,
isDisabled && styles.disabled,
isSelected && styles.selected,
xstyle,
diff --git a/packages/core/src/__tests__/pressState.ts b/packages/core/src/__tests__/pressState.ts
index 35e888a6df..e63a562542 100644
--- a/packages/core/src/__tests__/pressState.ts
+++ b/packages/core/src/__tests__/pressState.ts
@@ -20,7 +20,8 @@
* The touch arms are asserted the same way: the paint reads the press's
* strength (`--astryx-press-alpha`, see utils/interactionOverlay.stylex.ts)
* and the element the controller writes to runs the release animation on the
- * machine's own clock.
+ * machine's own clock; a list row's compositor layer (privateAttributes/press.stylex.ts)
+ * runs its own release on the row's `::before`, which these checks leave out.
*
* SYNC: When modified, update this header.
*/
@@ -242,7 +243,11 @@ export function durationToMs(value: string): number {
* on a descendant that merely reads the strength.
*/
export function hasReleaseFade(el: Element): boolean {
- const fading = rulesWithSelector(el, FADING_ARM);
+ // The element's own release: a layer of its own (a row's `::before`, a
+ // card's `::after`) runs its clock separately.
+ const fading = rulesWithSelector(el, FADING_ARM).filter(
+ rule => !rule.slice(0, rule.indexOf('{')).includes('::'),
+ );
const durations = fading.flatMap(rule => {
const match = rule.match(/animation-duration:\s*([^;}]+)/);
return match == null ? [] : [durationToMs(match[1])];
diff --git a/packages/core/src/privateAttributes/press.stylex.ts b/packages/core/src/privateAttributes/press.stylex.ts
new file mode 100644
index 0000000000..46e51d7393
--- /dev/null
+++ b/packages/core/src/privateAttributes/press.stylex.ts
@@ -0,0 +1,244 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/* eslint-disable @astryx/no-hover-on-disabled -- Every hover branch is
+ * nested beneath ENABLED below, as in interactionOverlay.stylex.ts. */
+
+/**
+ * @file privateAttributes/press.stylex.ts
+ * @input StyleX, the semantic overlay color tokens, the touch press strength
+ * (`pressVars`, utils/interactionOverlay.stylex.ts) and the row layer's
+ * clocks (utils/rowPressLayer.stylex.ts)
+ * @output `rowPressLayerStyles`: the compositor press layer for list rows
+ * (`cell`) and its own-image arms for a row on the `backgroundImage`
+ * variant (`cellOnImage`)
+ * @position Owner module of the private press attribute for the row layer:
+ * the press controller (utils/pressFeedback.ts) writes the attribute, and
+ * this file reads it. No package entry exports it. Item and TreeList
+ * compose these styles after their overlay variant;
+ * utils/interactionOverlay.cell.test.ts tests them.
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {colorVars} from '../theme/tokens.stylex';
+import {pressVars} from '../utils/interactionOverlay.stylex';
+import {cellPressConsts} from '../utils/rowPressLayer.stylex';
+
+// The overlay's arm selectors (interactionOverlay.stylex.ts), restated here:
+// StyleX resolves a style's keys within its own file.
+const ENABLED = ':where(:not(:disabled,[aria-disabled="true"]))';
+const HOVER_HOVER = '@media (hover: hover)';
+const COARSE = '@media (pointer: coarse)';
+const PRESSED_ON = '[data-astryx-press="on"]';
+const PRESSED_FADING = '[data-astryx-press="fading"]';
+/**
+ * A press in any of its states: the row layer exists only then, so at rest a
+ * row's own `::before` and its stacking are untouched.
+ */
+const PRESSED_ANY =
+ ':is([data-astryx-press="on"],[data-astryx-press="fading"])';
+
+const PRESS_ALPHA = pressVars['--astryx-press-alpha'];
+
+const hoverImage = `linear-gradient(${colorVars['--color-overlay-hover']}, ${colorVars['--color-overlay-hover']})`;
+const pressedImage = `linear-gradient(${colorVars['--color-overlay-pressed']}, ${colorVars['--color-overlay-pressed']})`;
+/** The overlay's paint, read back off the element (its gradient layer). */
+const pressedOverlayImage = 'var(--_press-paint-image)';
+
+/**
+ * The overlay's strength release (interactionOverlay.stylex.ts), restated so
+ * a fine pointer keeps it: the same keyframes, so the same animation.
+ */
+const pressRelease = stylex.keyframes({
+ from: {[PRESS_ALPHA]: 1},
+ to: {[PRESS_ALPHA]: 0},
+});
+
+/**
+ * The row layer's clock as CSS. It is the strength release's clock, scaled
+ * by the theme's `--_astryx-motion-tempo` up to 1.5, so the layer and the
+ * strength land together.
+ */
+const CELL_RELEASE = `calc(${cellPressConsts.cellReleaseMs}ms * min(var(--_astryx-motion-tempo, 1), 1.5))`;
+/** The same clock under Reduce Motion: a tempo may shorten it, never lengthen it. */
+const CELL_RELEASE_REDUCED = `min(${cellPressConsts.cellReleaseMs}ms, calc(${cellPressConsts.cellReleaseMs}ms * var(--_astryx-motion-tempo, 1)))`;
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+
+/** Opacity 1 → 0: the row layer leaves; its fading arm runs it. */
+const cellRelease = stylex.keyframes({
+ from: {opacity: 1},
+ to: {opacity: 0},
+});
+
+/** The release's curve: the table's gentle ease-out. */
+const RELEASE_EASE = cellPressConsts.cellReleaseEase;
+
+export const rowPressLayerStyles = stylex.create({
+ /**
+ * A list row's touch press on a compositor layer (Item, and TreeList's row
+ * box), composed AFTER the row's overlay variant (StyleX is last-wins per
+ * property). The variant's own touch paint, a gradient whose strength is a
+ * registered custom property, animates on the main thread: while script
+ * runs, a pressed row would stay at full strength and every frame of the
+ * fade would paint. Here the press is an element-sized `::before` under the
+ * row's content whose OPACITY is the strength: `on` shows it at once and
+ * `fading` runs a keyframe animation of its opacity, 1 → 0, on the cell's
+ * release clock (`timing.press`), which engines run on the compositor:
+ * it keeps advancing while the main thread is blocked and lays out and
+ * paints nothing. Same pixels as the variant's paint at that strength. The
+ * variant keeps the hover and a mouse's `:active`. The row must be
+ * positioned (the layer is placed absolutely); `isolation: isolate` keeps
+ * the layer above the row's background (a selected fill) and below its
+ * content. The layer exists only while a press is on or releasing: at rest
+ * a row's own `::before` and its stacking are as they were; during a press
+ * the layer is the row's `::before`, so a caller's decoration there merges
+ * into the layer for that time (decorate with `::after` or a child).
+ *
+ * Under a finger only (a coarse primary pointer): a fine pointer keeps the
+ * variant exactly, with no layer, no stacking context and its own touch
+ * paint, so a desktop row is as it was.
+ */
+ cell: {
+ // The `backgroundColor` variant's own image arms (Item's), its touch
+ // paint yielding to the layer under a finger. Only the row's own image
+ // turns off: the press paint (`--_press-paint`) stays the variant's, so
+ // what a row's descendants paint from it still paints. A fine pointer
+ // keeps the arms exactly. `cellOnImage` is the same for the
+ // `backgroundImage` variant (TreeList's row box).
+ backgroundImage: {
+ default: null,
+ [ENABLED]: {
+ default: null,
+ [PRESSED_ON]: {default: pressedOverlayImage, [COARSE]: 'none'},
+ [PRESSED_FADING]: {default: pressedOverlayImage, [COARSE]: 'none'},
+ },
+ },
+ // Under a finger the strength's own release (a main-thread animation)
+ // is dropped: the layer fades instead, on the compositor. A row whose
+ // descendant fades at the row's strength (a radio row's circle) brings
+ // it back with `pressedAlpha`. A fine pointer keeps it as the variant
+ // declares it (its clock and curve are untouched).
+ animationName: {
+ default: null,
+ [PRESSED_FADING]: {default: pressRelease, [COARSE]: 'none'},
+ },
+ // The stacking context the layer needs, for a press only.
+ isolation: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ANY]: 'isolate'},
+ },
+ // The whole layer is under a finger only, and only while a press is on
+ // or releasing: with a fine pointer none of it applies, and at rest a
+ // row's own `::before` is exactly as it was.
+ '::before': {
+ content: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [ENABLED]: {default: null, [PRESSED_ANY]: '""'},
+ },
+ },
+ position: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ANY]: 'absolute'},
+ },
+ inset: {default: null, [COARSE]: {default: null, [PRESSED_ANY]: 0}},
+ zIndex: {default: null, [COARSE]: {default: null, [PRESSED_ANY]: -1}},
+ borderRadius: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ANY]: 'inherit'},
+ },
+ pointerEvents: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ANY]: 'none'},
+ },
+ backgroundColor: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [PRESSED_ANY]: colorVars['--color-overlay-pressed'],
+ },
+ },
+ // On at once while the press is believed; nothing transitions it.
+ opacity: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ON]: 1, [PRESSED_FADING]: 0},
+ },
+ animationName: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [ENABLED]: {default: null, [PRESSED_FADING]: cellRelease},
+ },
+ },
+ animationDuration: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [PRESSED_FADING]: {
+ default: CELL_RELEASE,
+ [REDUCED_MOTION]: CELL_RELEASE_REDUCED,
+ },
+ },
+ },
+ animationTimingFunction: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [PRESSED_FADING]: RELEASE_EASE,
+ },
+ },
+ animationFillMode: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_FADING]: 'both'},
+ },
+ },
+ },
+ /**
+ * A row that keeps no press paint of its own, composed after `cell`: a
+ * radio row, whose circle paints the press. The row paints no overlay
+ * image, keeps the strength's own release (the circle's layer reads the
+ * strength), and under a finger has no `::before` box and is no stacking
+ * context during a press.
+ */
+ cellWithoutLayer: {
+ backgroundImage: 'none',
+ animationName: {default: null, [PRESSED_FADING]: pressRelease},
+ isolation: {
+ default: null,
+ [COARSE]: {default: null, [PRESSED_ANY]: 'auto'},
+ },
+ '::before': {
+ content: {
+ default: null,
+ [COARSE]: {
+ default: null,
+ [ENABLED]: {default: null, [PRESSED_ANY]: 'none'},
+ },
+ },
+ },
+ },
+ /**
+ * `cell`'s own-image arms for a row on the `backgroundImage` variant
+ * (TreeList's row box), composed after `cell`: the variant's arms, its
+ * touch press paint yielding to the layer under a coarse primary pointer.
+ */
+ cellOnImage: {
+ backgroundImage: {
+ default: null,
+ [ENABLED]: {
+ default: null,
+ ':active': {
+ default: pressedImage,
+ [COARSE]: 'none',
+ },
+ [HOVER_HOVER]: {
+ default: null,
+ ':hover': hoverImage,
+ ':active': pressedImage,
+ },
+ [PRESSED_ON]: {default: pressedOverlayImage, [COARSE]: 'none'},
+ [PRESSED_FADING]: {default: pressedOverlayImage, [COARSE]: 'none'},
+ },
+ },
+ },
+});
diff --git a/packages/core/src/utils/interactionOverlay.cell.test.ts b/packages/core/src/utils/interactionOverlay.cell.test.ts
new file mode 100644
index 0000000000..e051f05536
--- /dev/null
+++ b/packages/core/src/utils/interactionOverlay.cell.test.ts
@@ -0,0 +1,312 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file interactionOverlay.cell.test.ts
+ * @input vitest, the UIKit constants table (motion/uikit/timing.ts), the press
+ * layer style (`rowPressLayerStyles.cell`, privateAttributes/press.stylex.ts) and the rows that compose
+ * it (Item, TreeList)
+ * @output Holds the layer's build-time clock to the constants table, and
+ * asserts what a row ships for the touch press: the pressed token on a
+ * `::before` shown at once on the on arm, an opacity release on the fading
+ * arm on the cell clock, and none of the overlay's own main-thread release,
+ * all under a finger; a fine pointer's row as it was (no layer, no
+ * stacking context, the overlay's own paint); and that the layer and the
+ * overlay cap their release under reduced motion with the Reduce Motion
+ * constant, never a literal
+ * @position Unit test of the row press layer (privateAttributes/press.stylex.ts
+ * `rowPressLayerStyles.cell`, its clocks in utils/rowPressLayer.stylex.ts
+ * `cellPressConsts`); the real-engine proofs (compositor, busy main
+ * thread, curve) are in
+ * List/__tests__/ListRowPress.interaction.browser.spec.ts
+ */
+
+import {execFileSync} from 'node:child_process';
+import {readFileSync} from 'node:fs';
+import {resolve} from 'node:path';
+import * as stylex from '@stylexjs/stylex';
+import {createElement} from 'react';
+import {render, screen} from '@testing-library/react';
+import {describe, expect, it} from 'vitest';
+import {timing} from '../motion/uikit/timing';
+import {Item} from '../Item';
+import {TreeList} from '../TreeList';
+import {durationToMs, rulesDeclaredFor} from '../__tests__/pressState';
+import {interactionOverlayStyles} from './interactionOverlay.stylex';
+import {PRESS_FADE_MS} from './pressGesture';
+import {cellPressConsts} from './rowPressLayer.stylex';
+
+const ON = '[data-astryx-press="on"]';
+const FADING = '[data-astryx-press="fading"]';
+
+const selectorOf = (rule: string) => rule.slice(0, rule.indexOf('{'));
+const layerRules = (el: Element, arm: string) =>
+ rulesDeclaredFor(el).filter(rule => {
+ const selector = selectorOf(rule);
+ return selector.includes('::before') && selector.includes(arm);
+ });
+
+const COARSE = '(pointer: coarse)';
+
+const isHost = (rule: string) => !selectorOf(rule).includes('::before');
+
+/**
+ * The element's style rules inside an `@media` naming `media`, or outside
+ * every `@media` when `media` is null, as `selector {declarations}` text.
+ */
+function rulesIn(el: Element, media: string | null): string[] {
+ const classes = el.className
+ .split(/\s+/)
+ .filter(Boolean)
+ .map(name => `.${name}`);
+ const out: string[] = [];
+ const walk = (list: CSSRuleList, inside: string | null) => {
+ for (const rule of Array.from(list)) {
+ if (rule instanceof CSSMediaRule) {
+ walk(rule.cssRules, rule.media.mediaText);
+ } else if (rule instanceof CSSStyleRule) {
+ const selector = rule.selectorText;
+ const here = media == null ? inside == null : inside?.includes(media);
+ if (here && classes.some(cls => selector.startsWith(cls))) {
+ out.push(`${selector} {${rule.style.cssText}}`);
+ }
+ }
+ }
+ };
+ for (const sheet of Array.from(document.styleSheets)) {
+ try {
+ walk(sheet.cssRules, null);
+ } catch {
+ // A sheet the document cannot read holds no rule of ours.
+ }
+ }
+ return out;
+}
+
+/** Declarations of `property` in the element's rules, by value. */
+const values = (rules: string[], property: string) =>
+ rules.flatMap(rule => {
+ const match = rule.match(
+ new RegExp(`(?:^|[;{\\s])${property}:\\s*([^;}]+)`),
+ );
+ return match == null ? [] : [match[1].trim()];
+ });
+
+describe('press layer clock', () => {
+ it('plays the strength release’s tempo clock and its Reduce Motion cap, so the layer and the strength land together (spec:AST-108 FR4, FR4a)', () => {
+ const clocksOf = (file: string) =>
+ (
+ readFileSync(resolve(__dirname, file), 'utf8').match(
+ /`(?:calc|min)\([^`]*--_astryx-motion-tempo[^`]*\)`/g,
+ ) ?? []
+ ).map(clock => clock.replace(/\$\{[^}]+\}/g, '${ms}'));
+ const layer = clocksOf('../privateAttributes/press.stylex.ts');
+ expect(layer.length).toBe(2);
+ expect(new Set(layer)).toEqual(
+ new Set(clocksOf('interactionOverlay.stylex.ts')),
+ );
+ });
+
+ it('is the constants table’s press release, mirrored for the stylesheet', () => {
+ expect(cellPressConsts.cellReleaseMs).toBe(timing.press.highlightOutMs);
+ expect(cellPressConsts.cellReleaseEase).toBe(
+ `cubic-bezier(${timing.press.highlightOutCurve.join(', ')})`,
+ );
+ });
+
+ it('runs on the clock the controller checks the release at', () => {
+ expect(cellPressConsts.cellReleaseMs).toBe(PRESS_FADE_MS);
+ });
+
+ it("the shared overlay's release plays the same curve, the table's, from its own copy", () => {
+ const element = document.createElement('button');
+ element.className =
+ stylex.props(interactionOverlayStyles.pressedAlpha).className ?? '';
+ document.body.append(element);
+ const fading = rulesDeclaredFor(element).filter(rule => {
+ const selector = selectorOf(rule);
+ return selector.includes(FADING) && !selector.includes('::');
+ });
+ // StyleX writes the curve minified: compare the control points.
+ const points = (css: string) =>
+ (css.match(/-?\d*\.?\d+/g) ?? []).map(Number);
+ expect(values(fading, 'animation-timing-function').map(points)).toEqual([
+ [...timing.press.highlightOutCurve],
+ ]);
+ element.remove();
+ });
+});
+
+describe("the row layer's constants", () => {
+ it('reach only the components that render a press row: a Card ships none of them (architecture:component-style-authoring INV6)', () => {
+ // The shared overlay reaches nearly every component (`.stylex` modules
+ // are side effects in core's package.json), so whatever it imports does
+ // too. esbuild runs in its own process: it needs a native TextEncoder.
+ const script = [
+ "import {build} from 'esbuild';",
+ 'const result = await build({',
+ ` entryPoints: ${JSON.stringify([resolve(__dirname, '../Card/index.ts')])},`,
+ " bundle: true, write: false, format: 'esm', logLevel: 'silent',",
+ " external: ['react', 'react-dom', 'react/*', 'react-dom/*', '@stylexjs/stylex'],",
+ '});',
+ 'process.stdout.write(result.outputFiles.map(file => file.text).join("\\n"));',
+ ].join('\n');
+ const bundle = execFileSync(
+ process.execPath,
+ ['--input-type=module', '-e', script],
+ {cwd: resolve(__dirname, '../../../..'), encoding: 'utf8'},
+ );
+ // The shared overlay reaches the Card…
+ expect(bundle).toContain('astryx-press-alpha');
+ // …and brings none of the row layer's constants.
+ expect(bundle).not.toContain('cellRelease');
+ });
+});
+
+describe.each([
+ [
+ 'Item',
+ () => {
+ render(
+ createElement(Item, {
+ label: 'Row',
+ onClick: () => {},
+ 'data-testid': 'row',
+ }),
+ );
+ return screen.getByTestId('row');
+ },
+ ],
+ [
+ 'TreeList row',
+ () => {
+ render(
+ createElement(TreeList, {
+ items: [{id: 'a', label: 'Row', onClick: () => {}}],
+ }),
+ );
+ // The row box: the element the controller writes the press on.
+ return screen
+ .getByRole('treeitem')
+ .querySelector('[data-astryx-pressable]') as HTMLElement;
+ },
+ ],
+])('%s paints the touch press on a compositor layer', (_, mount) => {
+ it('shows the pressed token on its ::before at once while the press is on', () => {
+ const row = mount();
+ expect(row).toHaveAttribute('data-astryx-pressable');
+ const all = rulesDeclaredFor(row).filter(rule =>
+ selectorOf(rule).includes('::before'),
+ );
+ expect(values(all, 'background-color')).toEqual(
+ expect.arrayContaining([
+ expect.stringContaining('--color-overlay-pressed'),
+ ]),
+ );
+ expect(values(all, 'opacity')).toContain('0');
+ const on = layerRules(row, ON);
+ expect(values(on, 'opacity')).toEqual(['1']);
+ // The onset is instant: nothing animates on the on arm.
+ expect(values(on, 'animation-name')).toEqual([]);
+ });
+
+ it('releases with an opacity animation on the cell clock and curve', () => {
+ const row = mount();
+ const fading = layerRules(row, FADING);
+ expect(values(fading, 'animation-name')).toHaveLength(1);
+ // The clock, and its reduced-motion cap (DR2), both the table's value.
+ expect([
+ ...new Set(values(fading, 'animation-duration').map(durationToMs)),
+ ]).toEqual([timing.press.highlightOutMs]);
+ // StyleX writes the curve minified (`cubic-bezier(0,0,.2,1)`): compare
+ // the control points.
+ const points = (css: string) =>
+ (css.match(/-?\d*\.?\d+/g) ?? []).map(Number);
+ expect(values(fading, 'animation-timing-function').map(points)).toEqual([
+ [...timing.press.highlightOutCurve],
+ ]);
+ expect(values(fading, 'animation-fill-mode')).toEqual(['both']);
+ });
+
+ it('turns off only the row’s own image under a finger: the press paint stays for what the row’s descendants paint, and the release is the layer’s', () => {
+ const row = mount();
+ const coarse = rulesIn(row, COARSE).filter(isHost);
+ // The row's own image arms yield to the layer…
+ expect(
+ values(
+ coarse.filter(rule => rule.includes(ON)),
+ 'background-image',
+ ),
+ ).toEqual(['none']);
+ expect(
+ values(
+ coarse.filter(rule => rule.includes(FADING)),
+ 'background-image',
+ ),
+ ).toEqual(['none']);
+ // …while the paint a row's descendants read from it stays the
+ // overlay's own; the strength's main-thread release is dropped, the
+ // layer fading instead.
+ expect(values(coarse, '--_press-paint')).toEqual([]);
+ expect(values(coarse, '--_press-paint-image')).toEqual([]);
+ expect(
+ values(
+ coarse.filter(rule => rule.includes(FADING)),
+ 'animation-name',
+ ),
+ ).toEqual(['none']);
+ });
+
+ it('under a finger, nothing of the layer applies at rest: every rule of it waits for a press', () => {
+ const row = mount();
+ const coarse = rulesIn(row, COARSE);
+ // The layer's box, and the stacking context it needs, exist only while
+ // a press is on or releasing: at rest a row's own `::before` and its
+ // children's stacking are as they were.
+ const layer = coarse.filter(rule => !isHost(rule));
+ expect(layer.length).toBeGreaterThan(0);
+ for (const rule of layer) {
+ expect(selectorOf(rule), rule).toMatch(/data-astryx-press=/);
+ }
+ const isolation = coarse.filter(
+ rule => isHost(rule) && rule.includes('isolation:'),
+ );
+ expect(isolation).toHaveLength(1);
+ expect(selectorOf(isolation[0] ?? '')).toMatch(/data-astryx-press=/);
+ });
+
+ it('leaves a fine pointer’s row as it was: the overlay’s own paint and release, no layer, no stacking context', () => {
+ const row = mount();
+ const outside = rulesIn(row, null);
+ // The overlay's own touch paint and release, as the overlay declares
+ // them (spec:AST-017 FR59/DEC-25).
+ const paint = values(outside.filter(isHost), '--_press-paint');
+ expect(paint).toHaveLength(1);
+ expect(paint[0]).toContain('color-mix');
+ const release = values(
+ outside.filter(rule => isHost(rule) && rule.includes(FADING)),
+ 'animation-name',
+ );
+ expect(release).toHaveLength(1);
+ expect(release[0]).not.toBe('none');
+ // The layer's box and the stacking context it needs exist under a
+ // finger only: no declaration of the layer applies outside it, so a
+ // row's own `::before` keeps its opacity, stacking and hit testing.
+ expect(outside.filter(rule => !isHost(rule))).toEqual([]);
+ expect(values(outside, 'content')).toEqual([]);
+ expect(values(outside, 'isolation')).toEqual([]);
+ expect(values(rulesIn(row, COARSE), 'isolation')).toEqual(['isolate']);
+ expect(
+ values(
+ rulesIn(row, COARSE).filter(rule => !isHost(rule)),
+ 'content',
+ ),
+ ).toEqual(['""']);
+ });
+});
+
+it('a row without an action paints no press layer', () => {
+ render(createElement(Item, {label: 'Static', 'data-testid': 'row'}));
+ const row = screen.getByTestId('row');
+ expect(row).not.toHaveAttribute('data-astryx-pressable');
+ expect(layerRules(row, ON)).toEqual([]);
+});
diff --git a/packages/core/src/utils/interactionOverlay.exports.test.ts b/packages/core/src/utils/interactionOverlay.exports.test.ts
new file mode 100644
index 0000000000..e411f6f25f
--- /dev/null
+++ b/packages/core/src/utils/interactionOverlay.exports.test.ts
@@ -0,0 +1,54 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file interactionOverlay.exports.test.ts
+ * @input vitest, core's package.json, the published overlay module
+ * (interactionOverlay.stylex.ts) and the utils entry point (index.ts)
+ * @output Asserts the list row's press layer stays internal: neither
+ * `@astryxdesign/core/utils` nor `@astryxdesign/core/utils/interactionOverlay.stylex`
+ * exposes the row layer's styles (`cell`, `cellOnImage`), its clocks
+ * (`cellPressConsts`),
+ * and core's `exports` do not list the modules that hold them (`architecture:public-component-api` INV12)
+ * @position Unit test beside utils/interactionOverlay.stylex.ts and
+ * utils/rowPressLayer.stylex.ts
+ */
+
+import {readFileSync} from 'node:fs';
+import {join} from 'node:path';
+import {describe, expect, it} from 'vitest';
+import * as utils from './index';
+import * as overlay from './interactionOverlay.stylex';
+
+const ROW_LAYER_STYLES = ['cell', 'cellOnImage'];
+const ROW_LAYER_EXPORTS = ['cellPressConsts'];
+
+describe("the list row's press layer stays internal", () => {
+ it('is not exported from @astryxdesign/core/utils/interactionOverlay.stylex', () => {
+ for (const name of ROW_LAYER_EXPORTS) {
+ expect(overlay, name).not.toHaveProperty(name);
+ }
+ for (const name of ROW_LAYER_STYLES) {
+ expect(overlay.interactionOverlayStyles, name).not.toHaveProperty(name);
+ }
+ });
+
+ it('is not exported from @astryxdesign/core/utils', () => {
+ for (const name of ROW_LAYER_EXPORTS) {
+ expect(utils, name).not.toHaveProperty(name);
+ }
+ for (const name of ROW_LAYER_STYLES) {
+ expect(utils.interactionOverlayStyles, name).not.toHaveProperty(name);
+ }
+ });
+
+ it('lives in a module that core’s exports do not list', () => {
+ const pkg = JSON.parse(
+ readFileSync(join(process.cwd(), 'packages/core/package.json'), 'utf8'),
+ ) as {exports: Record<string, string | {source?: string}>};
+ const sources = Object.values(pkg.exports).map(entry =>
+ typeof entry === 'string' ? entry : entry.source,
+ );
+ expect(sources).not.toContain('./src/utils/rowPressLayer.stylex.ts');
+ expect(sources).not.toContain('./src/privateAttributes/press.stylex.ts');
+ });
+});
diff --git a/packages/core/src/utils/interactionOverlay.stylex.ts b/packages/core/src/utils/interactionOverlay.stylex.ts
index 67a619e618..fdc287f026 100644
--- a/packages/core/src/utils/interactionOverlay.stylex.ts
+++ b/packages/core/src/utils/interactionOverlay.stylex.ts
@@ -9,7 +9,8 @@
* @input StyleX and the semantic interaction-overlay color tokens
* @output Reusable background-color and background-image state styles, the
* touch press's registered strength variable (`pressVars`) and its clocks
- * (`pressConsts`)
+ * (`pressConsts`). The list row's compositor press layer and its clocks
+ * are internal (privateAttributes/press.stylex.ts, utils/rowPressLayer.stylex.ts)
* @position Internal styling utility for interactive core surfaces
*
* SYNC: When modified, update pressFeedback.ts, pressGesture.ts (the fade
@@ -148,7 +149,11 @@ const pressRelease = stylex.keyframes({
* (strength ≈ 0.2 at the midpoint), which is what a deselect crossfade reads
* as. Not the system's `--ease-standard`: that curve is for things that move,
* and is so front-loaded (strength 0.05 at the midpoint) that the release
- * would read as half its clock.
+ * would read as half its clock. It is the constants table's
+ * `timing.press.highlightOutCurve`, which the list row's layer mirrors too
+ * (rowPressLayer.stylex.ts); interactionOverlay.cell.test.ts fails if either
+ * drifts. A copy, not an import: this module reaches nearly every component,
+ * and the row layer's constants stay with the rows.
*/
const RELEASE_EASE = 'cubic-bezier(0, 0, 0.2, 1)';
diff --git a/packages/core/src/utils/pressableCoverage.test.ts b/packages/core/src/utils/pressableCoverage.test.ts
index d6509ed8d9..6431ef1607 100644
--- a/packages/core/src/utils/pressableCoverage.test.ts
+++ b/packages/core/src/utils/pressableCoverage.test.ts
@@ -32,9 +32,13 @@ import {describe, expect, it} from 'vitest';
const SRC = path.resolve(__dirname, '..');
-/** The utility and the controller define the model; they are not surfaces. */
+/**
+ * The utility, the list row's press layer and the controller define the
+ * model; they are not surfaces.
+ */
const MODEL_FILES = new Set([
'utils/interactionOverlay.stylex.ts',
+ 'privateAttributes/press.stylex.ts',
'utils/pressFeedback.ts',
'utils/pressGesture.ts',
]);
diff --git a/packages/core/src/utils/rowPressLayer.stylex.ts b/packages/core/src/utils/rowPressLayer.stylex.ts
new file mode 100644
index 0000000000..e350f16957
--- /dev/null
+++ b/packages/core/src/utils/rowPressLayer.stylex.ts
@@ -0,0 +1,27 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file rowPressLayer.stylex.ts
+ * @input StyleX
+ * @output The list row press layer's clocks (`cellPressConsts`)
+ * @position Internal to core: no package entry exports it. Only the row
+ * layer (privateAttributes/press.stylex.ts) reads it, so a component
+ * without a press row ships none of it; interactionOverlay.exports.test.ts
+ * keeps it off the published paths.
+ */
+
+import * as stylex from '@stylexjs/stylex';
+
+/**
+ * A list row's release (`rowPressLayerStyles.cell`), mirrored for the
+ * stylesheet. StyleX evaluates a style at build time and cannot read the
+ * constants table, so these are the table's press release values
+ * (`timing.press`, motion/uikit/timing.ts). interactionOverlay.cell.test.ts
+ * fails if they drift.
+ */
+export const cellPressConsts = stylex.defineConsts({
+ /** `timing.press.highlightOutMs`, in ms. */
+ cellReleaseMs: 200,
+ /** `timing.press.highlightOutCurve`, as CSS. */
+ cellReleaseEase: 'cubic-bezier(0, 0, 0.2, 1)',
+});
diff --git a/scripts/build-css.test.mjs b/scripts/build-css.test.mjs
index f559cf7246..4d75f08940 100644
--- a/scripts/build-css.test.mjs
+++ b/scripts/build-css.test.mjs
@@ -7,7 +7,9 @@
* Validates that astryx.css contains expected @media wrappers and
* prefers-reduced-motion rules, and that the touch press's release ships as a
* real fade: the press strength is a registered `<number>` the fading arm
- * animates on the machine's own clock (utils/interactionOverlay.stylex.ts).
+ * animates on the machine's own clock (utils/interactionOverlay.stylex.ts),
+ * and a list row's compositor press layer (privateAttributes/press.stylex.ts) releases
+ * its opacity on the cell clock and curve.
*/
import {describe, it, expect, beforeAll} from 'vitest';
@@ -276,8 +278,12 @@ describe('build-css astryx.css', () => {
/@keyframes ([\w-]+)\{from\{--astryx-press-alpha:1;?\}to\{--astryx-press-alpha:0;?\}\}/,
);
expect(keyframes).not.toBeNull();
- const fading = lines().filter(line =>
- line.includes('[data-astryx-press="fading"]'),
+ // The overlay's arms on the element itself; the compositor press
+ // layer's `::before` arms have their own block below.
+ const fading = lines().filter(
+ line =>
+ line.includes('[data-astryx-press="fading"]') &&
+ !line.includes('::before'),
);
expect(
fading.some(line => line.includes(`animation-name:${keyframes[1]}`)),
@@ -345,6 +351,76 @@ describe('build-css astryx.css', () => {
);
});
});
+ describe('the compositor press layer (privateAttributes/press.stylex.ts `cell`)', () => {
+ /** The cell clock and curve, read off their one stylesheet source. */
+ async function readLayerConsts() {
+ const source = await fs.readFile(
+ path.join(ROOT, 'packages/core/src/utils/rowPressLayer.stylex.ts'),
+ 'utf8',
+ );
+ const ms = source.match(/cellReleaseMs:\s*(\d+)/);
+ const ease = source.match(/cellReleaseEase:\s*'([^']+)'/);
+ if (ms == null || ease == null) {
+ throw new Error('cellPressConsts not found in rowPressLayer.stylex.ts');
+ }
+ return {
+ ms: Number(ms[1]),
+ points: ease[1].match(/-?\d*\.?\d+/g).map(Number),
+ };
+ }
+ const toMs = value => {
+ // The layer's release scales its base clock by the theme's tempo, as
+ // the strength's does (`calc(<ms> * …)`, `min(<ms>, …)`); it reads at
+ // tempo 1.
+ const match = value
+ .trim()
+ .match(/^(?:(?:calc|min)\(\s*)?([\d.]+)(ms|s)\b/);
+ return match == null
+ ? Number.NaN
+ : Number(match[1]) * (match[2] === 's' ? 1000 : 1);
+ };
+ const layerLines = arm =>
+ astryxCss
+ .split('\n')
+ .filter(line => line.includes(arm) && line.includes('::before'));
+
+ it('releases with an opacity keyframe animation on the cell clock and curve', async () => {
+ // Opacity, the property engines run on the compositor: the release
+ // keeps fading while script runs.
+ const keyframes = astryxCss.match(
+ /@keyframes ([\w-]+)\{from\{opacity:1;?\}to\{opacity:0;?\}\}/,
+ );
+ expect(keyframes).not.toBeNull();
+ const fading = layerLines('[data-astryx-press="fading"]');
+ expect(
+ fading.some(line => line.includes(`animation-name:${keyframes[1]}`)),
+ ).toBe(true);
+ const {ms, points} = await readLayerConsts();
+ const durations = fading
+ .map(line => line.match(/animation-duration:\s*([^;}]+)/))
+ .filter(Boolean)
+ .map(match => toMs(match[1]));
+ expect([...new Set(durations)]).toEqual([ms]);
+ const curves = fading
+ .map(line => line.match(/animation-timing-function:\s*([^;}]+)/))
+ .filter(Boolean)
+ .map(match => match[1].match(/-?\d*\.?\d+/g).map(Number));
+ // One curve, whether the Reduce Motion arm restates it or not.
+ expect([...new Set(curves.map(curve => curve.join(',')))]).toEqual([
+ points.join(','),
+ ]);
+ });
+
+ it('shows the layer at once on the on arm, and rests it at 0 on the fading arm under its release', () => {
+ const on = layerLines('[data-astryx-press="on"]');
+ expect(on.some(line => /\{opacity:1;?\}/.test(line))).toBe(true);
+ expect(on.some(line => line.includes('animation'))).toBe(false);
+ // Nothing of the layer at rest (a row's own `::before` is untouched):
+ // its opacity is only ever a press arm's.
+ const fading = layerLines('[data-astryx-press="fading"]');
+ expect(fading.some(line => /\{opacity:0;?\}/.test(line))).toBe(true);
+ });
+ });
describe('Layout header/footer padding collapse (Layout/layoutEdges.stylex.ts)', () => {
it('ships no :has() on the layout followed by a descendant * for the header or footer', () => {