Skip to content

fix(core): the click guard takes a claimed touch's late mousedown and mouseup - #9677

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:c09/click-guard-late-mouse
Nov 3, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:c09/click-guard-late-mouse

Conversation

@vjeux

@vjeux vjeux commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

User impact

On a phone, a held tap that a gesture claims still sends WebKit's late mousedown and mouseup to the page after the cancelled touchend, onto whatever is under the finger. A mousedown on page content blurs a field the tap just focused, so the keyboard drops; on a button, it starts a press.

Problem and solution fit

  1. Why it occurs: the click guard that the gesture host arms at a claimed lift takes only the click.
  2. Why it harms the task: a component that claims a tap gets an unasked press.
  3. Why it matters: each such component would need its own swallower; the touch runtime keeps one.

The gesture host now arms the guard at a claimed touch's lift with takesLateMouse, so it also takes that touch's mousedown and mouseup until the click, the next pointerdown or its window.

Expected behavior and authority

spec:AST-094 FR21: when a gesture takes a touch, no click or compatibility mouse event reaches the page. One added FR21 sentence, asked for by the maintainers, names the click guard as the one place that takes them. That record edit needs an engineering owner's /approve-spec on this head.

Smallest restoration

  • utils/clickGuard.ts: a takesLateMouse option that subscribes mousedown and mouseup while armed.
  • gestures/GestureHost.ts: only the touch arms pass it, a retargeted finger tap's included. A mouse or pen arm, and the menu press model's, take only the click, so a mouse press keeps its mouseup.
  • Events with detail 0, inside withoutClickGuard, or on the haptic switch still pass.

Closes #9623; Lab's SearchField then drops its own swallower.

Evidence

  • Reproduction before the change: a new browser case (a real claimed tap, then scripted late events, in Chromium and WebKit) and new clickGuard.test.ts cases failed on main.
  • Result after the change: both are taken until the click; the next press reaches the page.
  • Representative unchanged path: a plain arm leaves both.
  • Regression test or other mutation-sensitive proof: a resource case checks the guard holds them only while armed at a claimed lift.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

Local gates at b89b669, on main 5f3198e, with node 24.22.1 from .nvmrc: the build, Storybook, typecheck, strict ESLint (0 errors), Changeset coverage, export sync, i18n, CLI README and API types, token docs, Lab readiness, knowledge records and docsite data and tests pass. 739 UI test files (18,404 tests) and 860 node test files pass. The full interaction suite passes in Chromium (317 tests); the gestures browser specs pass in WebKit's CI profile (62 tests), and the new late-mouse case passes 10 of 10 there.

Records and clauses checked: spec:AST-094 FR21 (no compatibility mouse event after a claimed touch) and FR24 (listeners only while needed); architecture:react-component-runtime INV13 (one shared set of touch modules, document-wide input through one window listener per event type); architecture:knowledge-contracts INV29 (source comments).

Writing rubric results

spec:AST-094:

  • R1 narration: none; the new FR21 sentence states what the guard takes.
  • R2 research: none.
  • R3 evidence: the FR18–FR22 row's browser tests now include the late-mouse case.
  • R4 rejected alternatives: none added.
  • R5 change references: none added.
  • R6 open questions: none touched.

… mouseup

When a gesture takes a touch, spec:AST-094 FR21 keeps every click and
compatibility mouse event from the page. WebKit still sends a held tap's
mousedown and mouseup a few milliseconds after its cancelled touchend, aimed
at whatever is under the finger by then, and only the click was taken.

The gesture host now arms the shared click guard at a claimed touch's lift,
and at a retargeted finger tap's own click, with `takesLateMouse`: while
armed, the guard also takes that touch's mousedown and mouseup on Core's
shared window listener. They go with the click, the next pointerdown or the
guard's window. A mouse or pen arm, and
the menu press model's arm, take only the click as before; a mousedown with
detail 0, or one dispatched inside withoutClickGuard, passes.

AST-094 FR21 names the guard as the one place that takes them. With it, a
component that claims a held tap needs no swallower of its own. A browser
case taps a claiming recognizer in Chromium and WebKit, then sends the late
events from the page; on main, mousedown and mouseup reached it.

Closes meta#9623.
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 1:54am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 2:06 AM UTC

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b89b669

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
Slider 86.7 kB (+101 B) · 9.4 kB CSS (0) —
TopNavMenu 55.4 kB (+80 B) · 10.5 kB CSS (0) —
richtext/RichTextEditorToolbar 219.9 kB (+80 B) · 454 B CSS (0) —
18 more components
Component Size LoC
MoreMenu 71.2 kB (+77 B) · 15.4 kB CSS (0) —
DropdownMenuSubMenu 56.0 kB (+71 B) · 9.9 kB CSS (0) —
SideNavHeading 56.0 kB (+71 B) · 10.6 kB CSS (0) —
TopNavHeading 55.5 kB (+71 B) · 10.4 kB CSS (0) —
lab/Comments 230.4 kB (+69 B) · 2.5 kB CSS (0) —
Table 83.0 kB (+66 B) · 16.0 kB CSS (0) —
lab/CommentThread 225.0 kB (+66 B) · 2.4 kB CSS (0) —
DropdownMenu 70.9 kB (+65 B) · 15.4 kB CSS (0) —
PowerSearch 181.6 kB (+63 B) · 20.6 kB CSS (0) —
Markdown 143.7 kB (+62 B) · 18.3 kB CSS (0) —
TableCell 74.3 kB (+60 B) · 15.8 kB CSS (0) —
ContextMenu 73.1 kB (+57 B) · 15.3 kB CSS (0) —
BreadcrumbItem 65.0 kB (+56 B) · 11.4 kB CSS (0) —
TableHeaderCell 73.9 kB (+55 B) · 15.5 kB CSS (0) —
NavHeadingMenu 14.5 kB (+54 B) · 3.4 kB CSS (0) —
Pagination 84.3 kB (+51 B) · 16.0 kB CSS (0) —
TabMenu 52.5 kB (+49 B) · 10.4 kB CSS (0) —
Selector 75.3 kB (+41 B) · 15.7 kB CSS (0) —

Package size: @astryxdesign/core 5.94 MB packed (+840 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: core 1 row; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec b89b669

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready to approve. The touch arms now pass takesLateMouse, and the guard takes the late mousedown and mouseup only while it is armed. The new unit and browser cases cover the touch-event and retargeted paths. An engineering owner has approved the FR21 sentence for this head.

Two optional follow-ups:

  • Add a claimed-tap case with inputMode: 'pointer-events'. The arm at GestureHost.ts:3626 is the one late-mouse path no test exercises.
  • Drop the JSDoc on swallowLateMouse (clickGuard.ts:170). It restates the name, and the header above already explains the WebKit quirk.

[Automated review]

}
}

/** Swallows a claimed touch's late `mousedown` or `mouseup`. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional (comment style): this JSDoc restates swallowLateMouse. The header above already explains the WebKit quirk, so it can go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This approved head stays as it is; the one-line removal is ready as a follow-up if wanted.

);
if (!clicked && needsSuppression(dispositions)) {
armClickGuard(this.doc);
armClickGuard(this.doc, {takesLateMouse: event.pointerType === 'touch'});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: no test exercises this arm, a claimed tap read from pointer events. A claiming TapGestureRecognizer under inputMode: 'pointer-events', then late mousedown and mouseup, would pin it, like the retargeted case in presentedHitTesting.test.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. A pointer-events case for this arm is ready as a follow-up if wanted: a finger tap's late mousedown and mouseup are taken, and a mouse tap's own mouseup passes. This approved head stays as it is.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 04:33
@cixzhang
cixzhang merged commit 4a8a76e into meta:main Nov 3, 2026
112 checks passed
@vjeux
vjeux deleted the c09/click-guard-late-mouse branch November 3, 2026 05:03

This branch was successfully deployed

1 active deployment
Preview — b89b6693 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Click guard: also swallow a claimed touch's late mousedown and mouseup

2 participants