An open source design system that's fully customizable and agent ready
TypeScript
fix(List): a highlighted row's dividers stay visible through its tint (#10280)
Christopher Chedeaua6d2716de638
diff --git a/.changeset/list-dividers-over-tint.md b/.changeset/list-dividers-over-tint.mdnew file mode 100644index 0000000000..e8b083ba9a--- /dev/null+++ b/.changeset/list-dividers-over-tint.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] In a List with `hasDividers`, a hovered or pressed row keeps both of its dividers visible through its tint, with a mouse and under a finger. The divider above the row used to merge into the tint, and under a finger both dividers did. The dividers keep `--color-border`; nothing hides.++@vjeuxdiff --git a/docs/specs/components/List/List.spec.md b/docs/specs/components/List/List.spec.mdindex 7da2fb008a..21e244b949 100644--- a/docs/specs/components/List/List.spec.md+++ b/docs/specs/components/List/List.spec.md@@ -16,6 +16,7 @@ verified_by:packages/core/src/Item/Item.test.tsx,packages/core/src/List/ListItem.hitArea.test.tsx,packages/core/src/List/__tests__/ListTouchHitArea.interaction.browser.spec.ts,+ packages/core/src/List/__tests__/ListDividers.interaction.browser.spec.ts,packages/core/src/theme/derivedVarRegistry.test.ts,packages/core/src/theme/generateThemeRules.test.ts,apps/storybook/stories/List.stories.tsx,@@ -49,7 +50,7 @@ system_specs:| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ || 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). |+| 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), and every pointer keeps a highlighted row's dividers visible (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 implemented under coarse primary pointers. 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`. |@@ -97,7 +98,8 @@ Consumer migration instructions belong in consumer docs and release notes.- The relationship between row geometry and Item's density- and theme-awareinline inset.- Its rows' 44 px touch target under a coarse pointer (FR10).-- Its rows' press paint under a coarse pointer (FR11).+- Its rows' press paint under a coarse pointer, and a highlighted row's+ dividers for every pointer (FR11).- Its rows' update motion with an `animatedLayout` handle: entering, exiting,and crossing (FR12).- Its rows' menus attaching to the row's own `<li>` (FR13); the More actions@@ -134,7 +136,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 on the theme's exit motion tokens (`--duration-exit`, `--ease-exit`) 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. An interactive ListItem row also uses its `::after` as its touch hit area (FR10), so decorate such a row with a child. | `spec:AST-094` FR5, FR11; `component:List/DEC-6` | 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 on the theme's exit motion tokens (`--duration-exit`, `--ease-exit`) on the compositor (`spec:AST-094` FR5). A highlighted row (hovered, or pressed by any pointer) keeps both dividers visible in `--color-border` through its translucent tint; no divider hides or changes color for highlight (Owner decision, Nov 6 2026 (Cindy)). 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. An interactive ListItem row also uses its `::after` as its touch hit area (FR10), so decorate such a row with a child. | `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 |@@ -235,6 +237,7 @@ Consumer migration instructions belong in consumer docs and release notes.| FR2–FR6, FR8–FR9, AR1–AR2 | Real-browser List geometry evidence | each treatment in a Card at two paddings, a Section, an inline Dialog with and without Layout, a BottomSheet, a padded ScrollableArea scrolling vertically and in both axes, a LayoutContent with explicit padding, and standalone; header and dividers; LTR/RTL; hovered and selected rows; a swiped row under `outset` and `bleed` | Header movement, content off the expected line, paint past the host's padding edge, clipped resting paint, or a changed row box fails | `audit:List/visual` || FR10 | List tests of the touch hit target and real-browser hit-testing | every density; a row with a description; compact rows packed closer than 44 px; a row with an end control; a coarse and a fine pointer; a theme row padding | A coarse-pointer row whose target stays at its box where its neighbors leave room, a target that reaches a neighboring row's or control's target, a changed row box, or a changed fine-pointer target fails | `audit:List/layout` || FR11 | Item press-layer tests and real-browser pixel evidence | press, hold, and release; a release while the main thread is blocked; a mouse; a pressed row between two divided rows | A release that stops while script runs, an element added for the press, a divider hidden during a press, or paint or stacking changed at rest fails | `audit:List/visual` |+| FR11 dividers | Real-browser pixel evidence of each divider against the tint | a hovered row; a row pressed by a mouse and by a finger, and its release; light and dark | A divider whose contrast against the tint beside it drifts more than 0.05 from its rest contrast, a changed computed border, or an unpainted tint fails | `audit:List/visual` || FR12 | List update-motion tests and real-browser frame evidence | an insert, a removal, and a reorder, with and without a handle; reduced motion; a mouse; a start or end slot gaining, losing, and replacing content, and changing content at the same size; the reorder handle appearing; a focused slot control leaving; a leaving slot that sets the row's height | A staying row that jumps with a handle (other than after a leaving slot that sets the row's height), motion without one, a collapsing removed row that takes focus, pointer input or an accessibility-tree node, a removed row left after its collapse ends, or layout or paint per frame fails. Also fails: a slot change that jumps with a handle (other than a leaving slot that sets the row's height), a same-size slot change that animates, a leaving slot control that keeps focus or stays reachable, a focus move that scrolls, focus that lands on the page body, or a height-setting slot that plays an exit. | `audit:List/visual` || Migration | `astryx upgrade` codemod tests | static, aliased, already-migrated, dynamic, and computed-`edge` callsites; a second run | A dynamic value or a computed `edge` rewritten, a static one missed, or a second run that changes output fails | `audit:List/docs` || Documentation | `List.doc.mjs`, Storybook, and `scripts/check-knowledge.mjs` | public prop, values, default, deprecation, and representative composition | Missing or stale contract, docs, or example fails | `audit:List/docs` |diff --git a/packages/core/src/List/ListItem.tsx b/packages/core/src/List/ListItem.tsxindex 81b11413e9..48360b4b98 100644--- a/packages/core/src/List/ListItem.tsx+++ b/packages/core/src/List/ListItem.tsx@@ -42,6 +42,7 @@ import type {BaseProps} from '../BaseProps';import {ListContext, type ListMarker} from './ListContext';import {CheckboxInput} from '../CheckboxInput/CheckboxInput';import {mergeProps} from '../utils/mergeProps';+import {rowPressLayerStyles} from '../privateAttributes/press.stylex';import {Item, servesSwipeActions} from '../Item/Item';import {ItemListRowContext} from '../Item/ItemListRowContext';import {ItemMarkerColumnsContext} from '../Item/ItemMarkerColumnsContext';@@ -504,6 +505,7 @@ export function ListItem({hasMarkers && styles.withCounter,hasDividers && styles.withDivider,hasDividers && embeddedStyles.noRadius,+ hasDividers && isTouchTarget && rowPressLayerStyles.overDividers,isTouchTarget && touchHitAreaStyles.layer,isTouchTarget && isInList && styles.bandRaised,isRaisedSwipeRow && styles.swipeRaised,diff --git a/packages/core/src/List/__tests__/ListDividers.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListDividers.interaction.browser.spec.tsnew file mode 100644index 0000000000..b8e8582dad--- /dev/null+++ b/packages/core/src/List/__tests__/ListDividers.interaction.browser.spec.ts@@ -0,0 +1,322 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file ListDividers.interaction.browser.spec.ts+ * @input The built List "Compact" story (dividers between pressable rows) in+ * light and dark, real mouse and touch input, and the interaction harness+ * @output Proofs that a highlighted row keeps both of its dividers visible+ * through its tint. The row is hovered or pressed by a mouse, or pressed+ * by a finger under a coarse or a fine primary pointer. Each divider stands+ * out from the tint beside it as it stands out from its row at rest.+ * @position Real-engine layer for List's dividers; the touch release is in+ * ListRowPressPaths.interaction.browser.spec.ts+ */++// @ts-expect-error -- pngjs ships no declarations; runtime support is pinned.+import {PNG} from 'pngjs';+import {+ expect,+ test,+ type Browser,+ type Locator,+ type Page,+ type TestInfo,+} from '@astryxdesign/a11y-spec/playwright';+import {+ tap,+ touchDriver,+ withStorybook,+} from '@astryxdesign/interaction-harness';++const storybook = withStorybook(test);++const STORY = 'core-list--compact';+const SCHEMES = ['light', 'dark'] as const;+type Scheme = (typeof SCHEMES)[number];++/** How far a divider's contrast over the tint may drift from its rest. */+const CONTRAST_TOLERANCE = 0.05;++type Rgb = [number, number, number];++function luminance([r, g, b]: Rgb): number {+ const channel = (value: number) => {+ const c = value / 255;+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;+ };+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);+}++function contrast(a: Rgb, b: Rgb): number {+ const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);+ return (light + 0.05) / (dark + 0.05);+}++/**+ * The story at `scheme`, its three rows laid out. Rows are found inside the+ * story's root: Storybook's hidden error page has list items too.+ */+async function openList(page: Page, scheme: Scheme): Promise<void> {+ await page.goto(+ `${storybook()}/iframe.html?id=${STORY}&viewMode=story&globals=colorMode:${scheme}`,+ );+ await page+ .locator('#storybook-root li')+ .filter({hasText: 'Settings'})+ .first()+ .waitFor();+ await page.evaluate(async () => {+ await document.fonts.ready;+ });+}++const rowOf = (page: Page, label: string) =>+ page.locator('#storybook-root li').filter({hasText: label}).first();++/** The per-channel median of a one-CSS-pixel strip across the row's start. */+async function stripAt(page: Page, row: Locator, top: number): Promise<Rgb> {+ const box = await row.boundingBox();+ if (box == null) {+ throw new Error('no row');+ }+ const png = PNG.sync.read(+ await page.screenshot({+ clip: {x: box.x + 8, y: top, width: box.width / 2, height: 1},+ }),+ ) as {width: number; height: number; data: Uint8Array};+ const median = (offset: number) => {+ const values: number[] = [];+ for (let i = offset; i < png.data.length; i += 4) {+ values.push(png.data[i]);+ }+ values.sort((a, b) => a - b);+ return values[Math.floor(values.length / 2)];+ };+ return [median(0), median(1), median(2)];+}++/**+ * The two dividers of `row` and the surface beside each. They are the row+ * before's divider and `row`'s own, each one CSS pixel tall, and the strips+ * just inside `row`'s top and bottom edges.+ */+async function edgesOf(page: Page, above: Locator, row: Locator) {+ const box = await row.boundingBox();+ const width = await row.evaluate(el =>+ Number.parseFloat(getComputedStyle(el).borderBottomWidth),+ );+ if (box == null) {+ throw new Error('no row');+ }+ return {+ lineAbove: await stripAt(page, above, box.y - width),+ aboveInside: await stripAt(page, above, box.y - width - 3),+ insideTop: await stripAt(page, row, box.y + 2),+ insideBottom: await stripAt(page, row, box.y + box.height - width - 3),+ lineBelow: await stripAt(page, row, box.y + box.height - width),+ };+}++type Edges = Awaited<ReturnType<typeof edgesOf>>;++/** Each divider's contrast against the surface beside it. */+function contrasts(edges: Edges, beside: 'own row' | 'tint') {+ return {+ above: contrast(+ edges.lineAbove,+ beside === 'tint' ? edges.insideTop : edges.aboveInside,+ ),+ below: contrast(edges.lineBelow, edges.insideBottom),+ };+}++async function expectDividersDrawn(above: Locator, row: Locator) {+ for (const target of [above, row]) {+ const border = await target.evaluate(el => {+ const style = getComputedStyle(el);+ return {+ width: Number.parseFloat(style.borderBottomWidth),+ style: style.borderBottomStyle,+ };+ });+ expect(border.width).toBeGreaterThan(0);+ expect(border.style).toBe('solid');+ }+}++/**+ * Checks the highlighted row against the same row at rest. Its tint is+ * painted, and each divider stands out from the tint beside it as it stood+ * out from its row at rest.+ */+async function expectDividersThroughTint(+ page: Page,+ above: Locator,+ row: Locator,+ atRest: Edges,+ label: string,+) {+ await expectDividersDrawn(above, row);+ const highlighted = await edgesOf(page, above, row);+ const tintStep = Math.max(+ ...highlighted.insideTop.map((value, i) =>+ Math.abs(value - atRest.insideTop[i]),+ ),+ );+ expect(tintStep, `${label}: the tint is painted`).toBeGreaterThanOrEqual(3);+ const rest = contrasts(atRest, 'own row');+ const now = contrasts(highlighted, 'tint');+ for (const side of ['above', 'below'] as const) {+ expect(+ Math.abs(now[side] - rest[side]),+ `${label}: the divider ${side} reads ${now[side].toFixed(2)}:1 over the tint, ${rest[side].toFixed(2)}:1 at rest`,+ ).toBeLessThanOrEqual(CONTRAST_TOLERANCE);+ }+}++/** The same story with a mouse: the phone's viewport and scale, a fine pointer. */+async function withMouse<T>(+ browser: Browser,+ testInfo: TestInfo,+ run: (mousePage: Page) => Promise<T>,+): Promise<T> {+ const {viewport, deviceScaleFactor} = testInfo.project.use;+ const context = await browser.newContext({+ viewport,+ deviceScaleFactor,+ hasTouch: false,+ isMobile: false,+ });+ try {+ return await run(await context.newPage());+ } finally {+ await context.close();+ }+}++/** Longer than the hover tint's fade (the theme's fast duration). */+const SETTLE_MS = 400;++test.describe('a highlighted List row keeps both dividers visible through its tint', () => {+ for (const scheme of SCHEMES) {+ test(`${scheme}: hovered and pressed by a mouse`, async ({+ browser,+ }, testInfo) => {+ await withMouse(browser, testInfo, async page => {+ await openList(page, scheme);+ const above = rowOf(page, 'Notifications');+ const row = rowOf(page, 'Messages');+ const atRest = await edgesOf(page, above, row);+ const box = await row.boundingBox();+ if (box == null) {+ throw new Error('no row');+ }+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);+ await page.waitForTimeout(SETTLE_MS);+ await expectDividersThroughTint(page, above, row, atRest, 'hovered');+ await page.mouse.down();+ await page.waitForTimeout(SETTLE_MS);+ await expectDividersThroughTint(+ page,+ above,+ row,+ atRest,+ 'mouse press',+ );+ await page.mouse.up();+ });+ });++ // A laptop's touch screen: no touch emulation, so the primary pointer+ // stays fine, and the touches arrive through CDP.+ test(`${scheme}: pressed by a finger where the primary pointer is fine`, async ({+ browser,+ browserName,+ }, testInfo) => {+ test.skip(+ browserName !== 'chromium',+ 'a touch screen beside a fine primary pointer is emulated through CDP',+ );+ await withMouse(browser, testInfo, async page => {+ await openList(page, scheme);+ expect(+ await page.evaluate(() => matchMedia('(pointer: coarse)').matches),+ ).toBe(false);+ const above = rowOf(page, 'Notifications');+ const row = rowOf(page, 'Messages');+ const atRest = await edgesOf(page, above, row);+ const box = await row.boundingBox();+ if (box == null) {+ throw new Error('no row');+ }+ const driver = await touchDriver(page);+ await driver.play(+ tap(+ {x: box.x + box.width / 2, y: box.y + box.height / 2},+ {holdMs: 800},+ ),+ {+ onEvent: async (_step, index) => {+ if (index !== 0) {+ return;+ }+ await expect+ .poll(async () =>+ row.evaluate(el => el.getAttribute('data-astryx-press')),+ )+ .toBe('on');+ await expectDividersThroughTint(+ page,+ above,+ row,+ atRest,+ 'finger press, fine pointer',+ );+ },+ },+ );+ });+ });++ test(`${scheme}: pressed by a finger`, async ({page}) => {+ await openList(page, scheme);+ test.skip(+ !(await page.evaluate(() => matchMedia('(pointer: coarse)').matches)),+ 'the press layer serves a touch screen',+ );+ const above = rowOf(page, 'Notifications');+ const row = rowOf(page, 'Messages');+ const atRest = await edgesOf(page, above, row);+ const box = await row.boundingBox();+ if (box == null) {+ throw new Error('no row');+ }+ const driver = await touchDriver(page);+ await driver.play(+ tap(+ {x: box.x + box.width / 2, y: box.y + box.height / 2},+ {holdMs: 800},+ ),+ {+ onEvent: async (_step, index) => {+ if (index !== 0) {+ return;+ }+ await expect+ .poll(async () =>+ row.evaluate(el => el.getAttribute('data-astryx-press')),+ )+ .toBe('on');+ await expectDividersThroughTint(+ page,+ above,+ row,+ atRest,+ 'finger press',+ );+ },+ },+ );+ });+ }+});diff --git a/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.tsindex 87314d4b95..bbe05fb86f 100644--- a/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts+++ b/packages/core/src/List/__tests__/ListRowPressPaths.interaction.browser.spec.ts@@ -5,13 +5,12 @@* @input The built List "Interactive" and Press Feedback "Rows" stories, the* interaction harness, and the release clock (the default theme's* `--duration-exit`)- * @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+ * @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, which is 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 visible through its tint.* @position Interaction evidence for the row press layer* (privateAttributes/press.stylex.ts `rowPressLayerStyles.cell`), beside* ListRowPress.interaction.browser.spec.ts@@ -90,6 +89,57 @@ async function dividerOf(page: Page, row: Locator) {return {border, pixels: pixels.data, inside: inside.data};}+/** A row's surface just inside its top and bottom edges, decoded. */+async function surfacesOf(page: Page, row: Locator) {+ const box = await row.boundingBox();+ const width = await row.evaluate(el =>+ Number.parseFloat(getComputedStyle(el).borderBottomWidth),+ );+ if (box == null) {+ throw new Error('no row');+ }+ const strip = async (top: number) =>+ (+ PNG.sync.read(+ await page.screenshot({+ clip: {x: box.x + 12, y: top, width: box.width - 24, height: 1},+ }),+ ) as {data: Uint8Array}+ ).data;+ return {+ top: await strip(box.y + 2),+ bottom: await strip(box.y + box.height - width - 4),+ };+}++/** A decoded strip's per-channel median. */+function medianOf(data: Uint8Array): [number, number, number] {+ const channel = (offset: number) => {+ const values: number[] = [];+ for (let i = offset; i < data.length; i += 4) {+ values.push(data[i]);+ }+ values.sort((a, b) => a - b);+ return values[Math.floor(values.length / 2)];+ };+ return [channel(0), channel(1), channel(2)];+}++/** The contrast between two decoded strips' median colors. */+function contrastOf(a: Uint8Array, b: Uint8Array): number {+ const luminance = ([r, g, bl]: [number, number, number]) => {+ const linear = (value: number) => {+ const c = value / 255;+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;+ };+ return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(bl);+ };+ const [light, dark] = [luminance(medianOf(a)), luminance(medianOf(b))].sort(+ (x, y) => y - x,+ );+ return (light + 0.05) / (dark + 0.05);+}+/** The largest channel difference between two decoded strips. */function largestDifference(a: Uint8Array, b: Uint8Array): number {let largest = a.length === b.length ? 0 : 255;@@ -183,7 +233,7 @@ test('Reduce Motion keeps the release fade: a fade, not a movement', async ({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 ({+test('under a finger, a row held and released between two divided rows keeps both dividers visible through its tint, by computed border and contrast', async ({page,}) => {await openStory(page, storybook(), 'core-list--interactive', {@@ -211,18 +261,27 @@ test('under a finger, a row held and released between two divided rows keeps bot8,);}- /** Each divider as it is at rest, by computed border and by pixels. */+ /**+ * Each divider as drawn at rest. It keeps its computed border, and it+ * stands out from the pressed row's surface beside it as it did at rest.+ * The row before's divider sits against the pressed row's top, and its own+ * divider against the pressed row's bottom.+ */+ const restSurface = await surfacesOf(page, pressed);const expectDividersAsAtRest = async (phase: string) => {- for (const [name, target] of [- ['above', above],- ['pressed', pressed],+ const surface = await surfacesOf(page, pressed);+ for (const [name, target, side] of [+ ['above', above, 'top'],+ ['pressed', pressed, 'bottom'],] as const) {const now = await dividerOf(page, target);expect(now.border, `${phase}: ${name}`).toEqual(atRest[name].border);+ const rest = contrastOf(atRest[name].pixels, restSurface[side]);+ const pressedContrast = contrastOf(now.pixels, surface[side]);expect(- largestDifference(now.pixels, atRest[name].pixels),- `${phase}: ${name}'s divider pixels`,- ).toBeLessThanOrEqual(8);+ Math.abs(pressedContrast - rest),+ `${phase}: ${name}'s divider reads ${pressedContrast.toFixed(2)}:1 beside the pressed row, ${rest.toFixed(2)}:1 at rest`,+ ).toBeLessThanOrEqual(0.05);}};const box = await pressed.boundingBox();diff --git a/packages/core/src/privateAttributes/press.stylex.ts b/packages/core/src/privateAttributes/press.stylex.tsindex 5401e4b695..50d45701e2 100644--- a/packages/core/src/privateAttributes/press.stylex.ts+++ b/packages/core/src/privateAttributes/press.stylex.ts@@ -7,20 +7,25 @@* @file privateAttributes/press.stylex.ts* @input StyleX, the overlay color tokens, the touch press strength* (`pressVars`) and the theme's exit motion tokens- * @output `rowPressLayerStyles`, the compositor press layer for list rows- * (`cell`, `cellOnImage` for a `backgroundImage` row,- * `cellOnImagePressOnly` for a row whose fill is the hover tone), which- * Button also composes; `controlPressLayerStyles`, what Button adds to that- * layer (`control`); and `rowPressPaintStyles`, a CheckboxList row's press- * paint for its box+ * @output `rowPressLayerStyles`, the compositor press layer for list rows,+ * which Button also composes. Its styles: `cell`, and `cellOnImage` for a+ * `backgroundImage` row. `cellOnImagePressOnly` is for a row whose fill is+ * the hover tone, and `overDividers` for a row of a List with dividers. Also+ * `controlPressLayerStyles`, what Button adds to that layer (`control`),+ * and `rowPressPaintStyles`, a CheckboxList row's press paint for its box.* @position Owner module of the private press attribute: the press controller* (utils/pressFeedback.ts) writes it, and this file reads it. No package- * entry exports it. Item, TreeList, Button and CheckboxListItem compose its- * styles; utils/interactionOverlay.cell.test.ts tests the row layer.+ * entry exports it. Item, ListItem, TreeList, Button and CheckboxListItem+ * compose its styles; utils/interactionOverlay.cell.test.ts tests the row layer.*/import * as stylex from '@stylexjs/stylex';-import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';+import {+ borderVars,+ colorVars,+ durationVars,+ easeVars,+} from '../theme/tokens.stylex';import {reducedMotionFadeConsts} from '../motion/reducedMotion.stylex';import {pressVars} from '../utils/interactionOverlay.stylex';@@ -72,6 +77,13 @@ const cellRelease = stylex.keyframes({/** The release's curve: the theme's exit easing, as the strength's. */const RELEASE_EASE = easeVars['--ease-exit'];+/** A List divider's width (ListItem's bottom border). */+const DIVIDER_WIDTH = borderVars['--border-width'];+/** How far a highlighted row's tint reaches past its edge: one divider. */+const PAST_DIVIDER = `calc(-1 * ${DIVIDER_WIDTH})`;+/** A tint one divider tall, just above the row: over the row before's divider. */+const tintAbove = (tint: string) => `0 ${PAST_DIVIDER} 0 0 ${tint}`;+export const rowPressLayerStyles = stylex.create({/*** A touch press on a compositor layer (Item, TreeList's row box, and@@ -195,6 +207,62 @@ export const rowPressLayerStyles = stylex.create({},},},+ /**+ * A row of a List with dividers, composed after `cell`. Where the primary+ * pointer is fine, its own divider is its border, which paints over its+ * tint. The tint also covers the divider above it, as a shadow, under a+ * mouse or a finger. Under a coarse pointer, the press layer covers both+ * dividers, so they fade with it on the release. The tint is translucent,+ * so a divider under it reads as it does at rest.+ */+ overDividers: {+ boxShadow: {+ default: null,+ [ENABLED]: {+ default: null,+ ':not(:first-child)': {+ default: null,+ ':active': {+ default: tintAbove(colorVars['--color-overlay-pressed']),+ [COARSE]: 'none',+ },+ [HOVER_HOVER]: {+ default: null,+ ':hover': tintAbove(colorVars['--color-overlay-hover']),+ ':active': tintAbove(colorVars['--color-overlay-pressed']),+ },+ // A press the controller paints. Under a coarse pointer, the press+ // layer covers the divider above. Elsewhere the strip takes the+ // row's own press paint, which follows the release's strength.+ [PRESSED_ON]: {+ default: tintAbove('var(--_press-paint)'),+ [COARSE]: 'none',+ },+ [PRESSED_FADING]: {+ default: tintAbove('var(--_press-paint)'),+ [COARSE]: 'none',+ },+ },+ },+ },+ '::before': {+ insetBlockStart: {+ default: null,+ [COARSE]: {+ default: null,+ ':not(:first-child)': {default: null, [PRESSED_ANY]: PAST_DIVIDER},+ },+ },+ // The last row draws no divider (ListItem).+ insetBlockEnd: {+ default: null,+ [COARSE]: {+ default: null,+ ':not(:last-child)': {default: null, [PRESSED_ANY]: PAST_DIVIDER},+ },+ },+ },+ },/*** 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