Skip to content

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

TypeScript

a finger that lands on a paging settle never reaches its content (#10370)

Christopher Chedeauf9889f0f0eb3
diff --git a/.changeset/pager-catch-content.md b/.changeset/pager-catch-content.md
new file mode 100644
index 0000000000..d4fdb3f390
--- /dev/null
+++ b/.changeset/pager-catch-content.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Carousel paging: a finger or a pen that lands on a row still settling after a swipe no longer reaches the item under it: no press highlight and no click, as on iOS. A mouse click is unchanged.
+
+@vjeux
diff --git a/docs/specs/AST-094-touch-presentations/spec.md b/docs/specs/AST-094-touch-presentations/spec.md
index 5e58898af6..0c7dac780c 100644
--- a/docs/specs/AST-094-touch-presentations/spec.md
+++ b/docs/specs/AST-094-touch-presentations/spec.md
@@ -265,11 +265,14 @@ a measured, sourced difference exists.
velocity to the settle. The floor is a guess inside the measured bracket
(UIKit zeroes steady releases at 175 and 200 pt/s and keeps 249 pt/s, iOS
26.2 simulator, 2026-10-23) until a measurement replaces it (FR2). A page
- change during a drag starts from rest (DEC-25). A rebase toward the new
- rest shifts a spring heading there whole: its curve and target move by the
- rest's change, and it keeps its start time and velocity. On a starved page,
- the Switch's value change then shows no step in its frame proofs; any other
- retarget may still skip ahead by up to the browser's commit delay.
+ change during a drag starts from rest (DEC-25). A finger or a pen that lands
+ on a pager's settle after a release never reaches the pager's content: no
+ press feedback and no click. UIKit's content took none of 30 such touches
+ (iOS 26.2 simulator, 2026-11-06). A rebase toward the new rest shifts a
+ spring heading there whole: its curve and target move by the rest's change,
+ and it keeps its start time and velocity. On a starved page, the Switch's
+ value change then shows no step in its frame proofs; any other retarget may
+ still skip ahead by up to the browser's commit delay.
- **FR7 — Exits keep the native counterpart's look.** A touch presentation MUST
play an exit with the look of its UIKit counterpart's exit, on every touch
platform: a menu shrinks into its trigger, and an alert fades. In a component
@@ -398,7 +401,7 @@ a measured, sourced difference exists.
activation stays the browser's click, except that an action a
`family:action-groups` member tracks activates at the lift (FR26), and a toggle
under `spec:AST-020` FR9's slide-off exception (Switch, Checkbox,
- CheckboxListItem) may also complete on a lift after the finger slid off; and a Switch completes its own toggle at the lift of a finger hold or a flipping drag, rather than through the browser's click (`component:Switch` FR15); and a SegmentedControl drag commits at the lift on the segment nearest the pointer, wherever it began (`component:SegmentedControl` FR13). Where the engine hit-tests an element a compositor animation moves at the motion's start (iOS WebKit), a touch on moving content goes to what was drawn under the finger at touch-down, and a tap there (no recognizer claimed it, the browser did not take it, and it stayed within 45 pt) MUST activate it: the browser's own click for that touch is cancelled or swallowed, and that element receives one click, an editable focused first.
+ CheckboxListItem) may also complete on a lift after the finger slid off; and a Switch completes its own toggle at the lift of a finger hold or a flipping drag, rather than through the browser's click (`component:Switch` FR15); and a SegmentedControl drag commits at the lift on the segment nearest the pointer, wherever it began (`component:SegmentedControl` FR13). Where the engine hit-tests an element a compositor animation moves at the motion's start (iOS WebKit), a touch on moving content goes to what was drawn under the finger at touch-down, and a tap there (no recognizer claimed it, the browser did not take it, and it stayed within 45 pt) MUST activate it: the browser's own click for that touch is cancelled or swallowed, and that element receives one click, an editable focused first. A pager's settle after a release is the exception: a finger or a pen that lands on it never reaches the content (FR6).
Under a fine pointer a control uses a third profile with no delay: its
press paint starts at once on `pointerdown`, through the same press
controller and release fade as a finger's, in place of CSS `:active`; the
diff --git a/packages/core/src/SnapPaging/__tests__/SnapPaging.interaction.browser.spec.ts b/packages/core/src/SnapPaging/__tests__/SnapPaging.interaction.browser.spec.ts
index 348f42893f..97cc2947fe 100644
--- a/packages/core/src/SnapPaging/__tests__/SnapPaging.interaction.browser.spec.ts
+++ b/packages/core/src/SnapPaging/__tests__/SnapPaging.interaction.browser.spec.ts
@@ -470,6 +470,79 @@ for (const holdMs of [150, 40]) {
});
}
+// The touch that stops a scroll view never reaches its content (UIKit).
+test.describe("a touch that lands on a flick's settle", () => {
+ /** Counts clicks that reach the row's items. */
+ async function countItemClicks(scroller: Locator) {
+ await scroller.evaluate(el => {
+ const w = window as unknown as {__itemClicks: number};
+ w.__itemClicks = 0;
+ el.addEventListener('click', () => {
+ w.__itemClicks += 1;
+ });
+ });
+ return async () =>
+ scroller.evaluate(
+ () => (window as unknown as {__itemClicks: number}).__itemClicks,
+ );
+ }
+
+ /** Flicks the row from rest and waits until the paging holds it. */
+ async function flickToSettle(page: Page, scroller: Locator) {
+ await swipe(page, scroller, {px: 80, ms: 80});
+ await expect
+ .poll(async () => isTakenOver(scroller), {intervals: [5]})
+ .toBe(true);
+ }
+
+ test('a tap during the settle clicks no item', async ({page}) => {
+ const {scroller} = await open(page, 'snap-paging-three-up', 'paging');
+ const box = await scroller.boundingBox();
+ if (box == null) {
+ throw new Error('no scroller');
+ }
+ const clicks = await countItemClicks(scroller);
+ await flickToSettle(page, scroller);
+ const driver = await touchDriver(page);
+ // The engine's own tap path: WebKit synthesises a click only from it.
+ await driver.tap({x: box.x + box.width / 2, y: box.y + box.height / 2});
+ await settled(scroller);
+ expect(await clicks()).toBe(0);
+ });
+
+ test('a 150 ms hold during the settle clicks no item', async ({page}) => {
+ const {scroller} = await open(page, 'snap-paging-three-up', 'paging');
+ const box = await scroller.boundingBox();
+ if (box == null) {
+ throw new Error('no scroller');
+ }
+ const clicks = await countItemClicks(scroller);
+ await flickToSettle(page, scroller);
+ const driver = await touchDriver(page);
+ await driver.play(
+ tap({x: box.x + box.width / 2, y: box.y + box.height / 2}, {holdMs: 150}),
+ );
+ await settled(scroller);
+ // WebKit synthesises a click only from its own tap path, not from a raw
+ // touch sequence (harness README, engine limits); Chromium does from both.
+ if (driver.engine === 'chromium') {
+ expect(await clicks()).toBe(0);
+ }
+ });
+
+ test('a tap on the resting row still clicks the item', async ({page}) => {
+ const {scroller} = await open(page, 'snap-paging-three-up', 'paging');
+ const box = await scroller.boundingBox();
+ if (box == null) {
+ throw new Error('no scroller');
+ }
+ const clicks = await countItemClicks(scroller);
+ const driver = await touchDriver(page);
+ await driver.tap({x: box.x + box.width / 2, y: box.y + box.height / 2});
+ await expect.poll(clicks).toBe(1);
+ });
+});
+
test.describe('with a finger and a mouse', () => {
test.use({hasTouch: true, isMobile: false});
diff --git a/packages/core/src/gestures/GestureArena.ts b/packages/core/src/gestures/GestureArena.ts
index 46d8084fdd..62bf6d0337 100644
--- a/packages/core/src/gestures/GestureArena.ts
+++ b/packages/core/src/gestures/GestureArena.ts
@@ -513,6 +513,11 @@ export class GestureArena {
}
}
+ /** @internal A recognizer takes its touches from the view, unclaimed. */
+ cancelTouchesInViewOf(recognizer: GestureRecognizer): void {
+ this.cancelViewTouchesOf(recognizer);
+ }
+
/**
* Runs `body`, code outside input that stops recognizers (an Effect that
* turns one off or detaches it), without resolving what those stops
@@ -629,7 +634,9 @@ export class GestureArena {
}
this.claim(recognizer);
// A watcher takes nothing from the view either: the press and the click
- // under it stay (spec:AST-094 FR11, FR19; FR15 exempts watchers).
+ // under it stay (spec:AST-094 FR11, FR19; FR15 exempts watchers). Only
+ // `cancelTouchesInView` takes them, as a pager's catch on a release's settle
+ // does.
if (recognizer.claimsTouches && recognizer.cancelsTouchesInView) {
this.cancelViewTouchesOf(recognizer);
}
diff --git a/packages/core/src/gestures/GestureRecognizer.ts b/packages/core/src/gestures/GestureRecognizer.ts
index 34115df154..9ced109749 100644
--- a/packages/core/src/gestures/GestureRecognizer.ts
+++ b/packages/core/src/gestures/GestureRecognizer.ts
@@ -559,6 +559,15 @@ export abstract class GestureRecognizer {
return this.arena?.now() ?? 0;
}
+ /**
+ * Takes this recognizer's touches from the view, as a claiming winner does
+ * under `cancelsTouchesInView`: the view's press ends and no click follows.
+ * The touches stay unclaimed, so the page still scrolls.
+ */
+ protected cancelTouchesInView(): void {
+ this.arena?.cancelTouchesInViewOf(this);
+ }
+
// --- Arena hooks (internal) ----------------------------------------------
/** @internal Whether this recognizer takes `touch` right now. */
diff --git a/packages/core/src/hooks/usePager.test.ts b/packages/core/src/hooks/usePager.test.ts
index be75aae810..e50f0f4210 100644
--- a/packages/core/src/hooks/usePager.test.ts
+++ b/packages/core/src/hooks/usePager.test.ts
@@ -883,6 +883,88 @@ describe('createPager', () => {
expect(f.x()).toBe(-3 * WIDTH);
});
+ // spec:AST-094 FR6: the touch that stops a scroll view never reaches its
+ // content (UIKit).
+ describe('a finger that lands on a release settle', () => {
+ async function releaseSettle(): Promise<Fixture> {
+ const f = setup({defaultIndex: 0});
+ await drag(f, {from: 300, dx: -120});
+ await advance(16, f.clock);
+ expect(f.pager.isSettling).toBe(true);
+ return f;
+ }
+ function countClicks(target: EventTarget): () => number {
+ let clicks = 0;
+ target.addEventListener('click', () => (clicks += 1));
+ return () => clicks;
+ }
+ function click(target: EventTarget): void {
+ target.dispatchEvent(
+ // A pointer's click: the click guard lets a `detail` 0 click pass.
+ new MouseEvent('click', {bubbles: true, cancelable: true, detail: 1}),
+ );
+ }
+
+ it('takes a 40 ms tap from the content: no click, and the settle runs on', async () => {
+ const f = await releaseSettle();
+ const clicks = countClicks(f.page);
+ touch('touchstart', f.page, 300, 100, now);
+ await advance(40, f.clock);
+ const end = touch('touchend', f.page, 300, 100, now);
+ click(f.page);
+ expect(end.defaultPrevented).toBe(true);
+ expect(clicks()).toBe(0);
+ expect(f.pager.isSettling).toBe(true);
+ });
+
+ it('takes a 150 ms hold from the content too', async () => {
+ const f = await releaseSettle();
+ const clicks = countClicks(f.page);
+ touch('touchstart', f.page, 300, 100, now);
+ await advance(150, f.clock);
+ const end = touch('touchend', f.page, 300, 100, now);
+ click(f.page);
+ expect(end.defaultPrevented).toBe(true);
+ expect(clicks()).toBe(0);
+ });
+
+ it('leaves a mouse click alone (spec:AST-017 FR59)', async () => {
+ const f = await releaseSettle();
+ stubMedia(false, false);
+ const clicks = countClicks(f.page);
+ mouse('pointerdown', f.page, 300, 100, now);
+ await advance(40, f.clock);
+ mouse('pointerup', f.page, 300, 100, now);
+ click(f.page);
+ expect(clicks()).toBe(1);
+ });
+
+ it('is not a rule for a resting track or a goTo move: their taps click', async () => {
+ const rest = setup({defaultIndex: 0});
+ const restClicks = countClicks(rest.page);
+ touch('touchstart', rest.page, 300, 100, now);
+ await advance(40, rest.clock);
+ const restEnd = touch('touchend', rest.page, 300, 100, now);
+ click(rest.page);
+ expect(restEnd.defaultPrevented).toBe(false);
+ expect(restClicks()).toBe(1);
+ rest.pager.dispose();
+ document.body.innerHTML = '';
+
+ const moving = setup({defaultIndex: 0});
+ moving.pager.goTo(2);
+ await advance(0, moving.clock);
+ await advance(60, moving.clock);
+ const movingClicks = countClicks(moving.page);
+ touch('touchstart', moving.page, 300, 100, now);
+ await advance(40, moving.clock);
+ const movingEnd = touch('touchend', moving.page, 300, 100, now);
+ click(moving.page);
+ expect(movingEnd.defaultPrevented).toBe(false);
+ expect(movingClicks()).toBe(1);
+ });
+ });
+
it('goTo with an offset ends there as a settle, and a still finger that catches it settles on the nearest page', async () => {
const f = setup({defaultIndex: 0});
f.pager.goTo(2, {offset: 2.4 * WIDTH});
diff --git a/packages/core/src/hooks/usePager.ts b/packages/core/src/hooks/usePager.ts
index d489235954..ebf0dd9d5c 100644
--- a/packages/core/src/hooks/usePager.ts
+++ b/packages/core/src/hooks/usePager.ts
@@ -412,6 +412,14 @@ class SettleCatcher extends LongPressGestureRecognizer {
this.clearTimer();
}
+ /**
+ * Takes the touch from the content under it: no press and no click. In
+ * UIKit, the touch that stops a scroll view never reaches its content.
+ */
+ takeFromContent(): void {
+ this.cancelTouchesInView();
+ }
+
protected override touchesBegan(
touches: ReadonlyArray<GestureTouch>,
event: GestureEventContext,
@@ -650,6 +658,8 @@ export function createPager(
let settled = target;
let settleHandle: MotionHandle | null = null;
let isSwipeSettle = false;
+ // Whether the running settle follows a release, not the program's `goTo`.
+ let isReleaseSettle = false;
let settleToken = 0;
let isDragging = false;
@@ -721,6 +731,7 @@ export function createPager(
clearCatchTimer();
flushReport();
isSwipeSettle = false;
+ isReleaseSettle = false;
if (settleHandle != null) {
settleToken += 1;
settleHandle = null;
@@ -874,10 +885,16 @@ export function createPager(
* travel. A settle that a touch's release starts (`touchRelease`)
* cross-fades on any pointer. Any other motion, such as `goTo` or a mouse's
* or a pen's release, cross-fades on a coarse pointer. It lands at once on
- * any other pointer.
+ * any other pointer. `isRelease` marks a release's settle, which a finger
+ * that catches it takes from the content.
*/
- function play(curve: MotionCurve, touchRelease = false): void {
+ function play(
+ curve: MotionCurve,
+ touchRelease = false,
+ isRelease = false,
+ ): void {
isSwipeSettle = false;
+ isReleaseSettle = isRelease;
if (animator == null) {
return;
}
@@ -925,7 +942,7 @@ export function createPager(
rest();
return;
}
- play(curve, touchRelease);
+ play(curve, touchRelease, true);
}
function measure(): void {
@@ -1088,6 +1105,10 @@ export function createPager(
function onCatch(recognizer: LongPressGestureRecognizer): void {
if (recognizer.state === 'began') {
holdSelection(true);
+ // A mouse keeps its click. A finger or a pen loses it.
+ if (isReleaseSettle && catcher.pointerType !== 'mouse') {
+ catcher.takeFromContent();
+ }
clearCatchTimer();
caughtSettle = false;
isCatchTimerArmed = true;