Skip to content

fix(core): skip unrendered content during touch hit-area measurement - #11885

Open
sunven wants to merge 1 commit into
meta:mainfrom
sunven:fix/hit-area-skipped-content
Open

sunven wants to merge 1 commit into
meta:mainfrom
sunven:fix/hit-area-skipped-content

Conversation

@sunven

@sunven sunven commented Nov 15, 2026 •

Copy link
Copy Markdown

User impact

On touch pages with offscreen content-visibility: auto sections, measuring a visible control also reads the bounds of skipped interactive descendants. Those reads force rendering work in deferred content and undermine the page's layout optimization.

Fixes #11883.

Problem and solution fit

readCandidates() measures every cached interactive element, even when its ancestor's contents are skipped. Filter unrendered candidates before reading geometry, so visible controls can keep their touch targets without forcing deferred descendants to render.

Expected behavior and authority

AST-094 FR42 owns touch targets growing toward 44 × 44 px, stopping halfway to neighbours. FR24 and React component runtime INV5/INV7 govern shared interaction work and resource ownership. This change preserves the existing sizing and scheduling rules while avoiding geometry reads for skipped content.

Smallest restoration

 interactiveElements(doc)
+  .filter(el => !el.checkVisibility || el.checkVisibility({contentVisibilityAuto: true}))
   .map(el => ({element: el, rect: plainRect(el)}))

The registry remains intact: revealed elements rejoin subsequent measurements. Browsers without checkVisibility retain existing behavior. Supporting changes are two unit regressions, one browser regression and a Core patch changeset.

Evidence

  • Before: the new unit regression failed; Chromium and WebKit each recorded 2 bounds reads from skipped descendants while measuring a visible control.
  • After: 0 skipped bounds reads in both browsers. Scrolling the hidden control into view restores measurement; its right inset is 4 px beside a neighbour with an 8 px gap, and tapping it fires a click.
  • Unchanged path: the unit regression preserves neighbour clearance when checkVisibility is unavailable; the existing hit-area suite passes.
  • Regression proof: removing the filter makes the new skipped-read assertions fail in unit tests and both browsers.
  • Size: isolated minified hitArea.ts ESM bundle, including transitive imports: gzip 6,033 → 6,060 bytes (+27 bytes); no CSS change. This is not a full application bundle measurement.

Scope

Components: shared Core hitArea utility.

  • 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.

Related: #11205 replaces the watched hit-area architecture more broadly. This patch targets the current implementation and can be considered independently if useful before that refactor lands.

Testing

Completed before opening this draft:

  • pnpm exec vitest run packages/core/src/utils/hitArea.test.ts --project ui — 63 passed.
  • pnpm exec playwright test --config playwright.interaction.config.ts hitAreaContentVisibility.interaction.browser.spec.ts — 2 passed, Chromium and WebKit with touch input.
  • pnpm lint:strict — 0 errors, warnings reported.
  • Commit hooks: lint-staged and pnpm check:repo — passed on the committed files.
  • pnpm specs:for --diff origin/main and pnpm review:pre --base upstream/main — completed; pre-review reported no automatic findings.

Validation limits: the full pnpm test --maxWorkers=4 run was stopped after failures appeared in unchanged CLI tests, including theme-edit and kept-tree tests. These failures have not been compared against a clean upstream checkout. The browser fixture then received a small lint cleanup removing non-null assertions; its browser run was not repeated. pnpm build has not been run. This draft does not claim the full repository gates pass.

Fresh-session pre-review receipt

Reviewed base 8c8dd0539e01795f04b4056b440c2f77db05e7e6 against head 70536e40fc728509160e1f07f05f67d7abfd2878: no actionable findings. The committed review:pre report has 0 automatic findings and a clean merge. Public API, behavior authority, public boundary and source comments were checked.

Global routing matched the following 63 claims. Each match reason is that the listed trigger matches that claim's review-applicability:v1 declaration; only those claims were routed. Direct behavior ownership remains AST-094 FR42.

Record Claims Trigger
architecture:component-test-sufficiency INV1–7, INV10, INV11 testing
architecture:interaction-modality INV1–4, INV7, INV8, INV11 interaction
architecture:rtl-audit-evidence INV1–4, INV6, INV9, INV10, INV12–14, INV16 testing
design:bidirectionality DR1, DR6, DR8, DR10–13 interaction
design:bidirectionality DR1, DR6, DR10, DR13 scrolling
family:action-groups FR1–5 interaction
spec:AST-013 FR1, FR3, FR5–10, FR12, FR13 platform
spec:AST-025 FR1, FR12–16, FR18 scrolling
spec:AST-030 FR7, FR11, FR30 testing

Merge Danger

Door: two-way; revert the candidate filter to restore previous behavior.

Blast Radius: touch-targets. Shared neighbour measurement changes for unrendered candidates; visible targets, revealed neighbours and the unsupported-browser fallback have focused coverage.

@vercel

vercel Bot commented Nov 15, 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 15, 2026 3:07pm UTC

Request Review

@meta-cla

meta-cla Bot commented Nov 15, 2026

Copy link
Copy Markdown

Hi @sunven!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@astracat-bot

astracat-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 16, 2026, 3:05 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 15, 2026
@sunven
sunven marked this pull request as ready for review November 16, 2026 02:39

@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.

Changes requested — one evidence gap, no code defect.

The filter itself holds up at this revision: the new unit regression and the new Chromium browser regression both fail against main's implementation and pass here, the revealed control still stops 4 px short of its neighbour and takes its tap, and the existing hit-area suite stays green at 63 tests.

  • packages/core/src/utils/hitArea.ts is imported by five component folders, so a pull request that grows it reports the first-load gzip delta on the four reference pages (docs, form, menu, table), base against head, under architecture:component-import-boundaries INV10; the Evidence section gives an isolated hitArea.ts bundle instead and notes itself that it is not an application measurement. Run pnpm size:pages --base origin/main and put its table in the Evidence section — this review measured +0, +30, +26 and +24 bytes gzip, all inside INV10's 0.3 KB allowance, so this is a reporting fix rather than a code change.

One thing outside your hands: CI has not run on this head, so the WebKit interaction project your Evidence section cites has no result here — a maintainer adds the ci:run label so the required checks run.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Changeset, hit-area measurement skips content hidden by content-visibility without forcing its descendants to render — verified: the filter in hitArea.ts (lines 674-687), and a Chromium probe counting 1 forced layout for the first pass on the base page against 0 on the head's.
  • readCandidates() measured every cached interactive element even when its ancestor's contents were skipped — verified against the base implementation.
  • Before the change, the new unit regression failed and Chromium recorded 2 bounds reads from skipped descendants — verified: the base tree carrying the head's test files fails at hitArea.test.ts:340, and the browser regression fails there with "Expected: 0, Received: 2".
  • WebKit recorded 2 reads before and 0 after — not reproducible on the review machine, which cannot launch WebKit; not counted against this pull request.
  • After the change, 0 skipped reads, the revealed control's right inset is 4 px beside its 8 px-away neighbour, and tapping it fires a click — verified: the browser regression passes on the head.
  • The unchanged path is preserved where checkVisibility is unavailable, and the existing hit-area suite passes — verified: 63 unit tests pass, including the second new regression.
  • Isolated minified hitArea.ts bundle, gzip 6,033 → 6,060 bytes (+27), no CSS change — verified: 6,033 → 6,060 bytes at the default gzip level, and the diff touches no stylesheet.
  • pnpm lint:strict reports 0 errors — verified for the three changed source files under strict lint; the full-repository run is CI's.
  • The full test run was stopped after failures in unchanged CLI tests and pnpm build was not run — taken as stated; this review built the build package, Core and the seven themes in both trees with no failure.
  • The pre-review receipt reports no actionable findings — not reproducible here (a fresh-session receipt), and nothing in it is relied on.
  • Related work replaces the watched hit-area architecture more broadly and this patch is independent — verified: that pull request is an open draft and nothing here depends on it.

Files:

  • .changeset/skip-unrendered-hit-area-candidates.md — clear: a valid @astryxdesign/core patch note, accepted by the repository's changeset check.
  • packages/core/src/utils/hitArea.ts — clear: the candidate filter and its capability guard; no other path in the file changes.
  • packages/core/src/utils/hitArea.test.ts — clear: two regressions, both mutation-sensitive (one fails without the filter, one pins the fallback).
  • packages/core/src/utils/__tests__/hitAreaContentVisibility.interaction.browser.spec.ts — clear: matches the interaction lanes' test pattern and follows the repository's existing esbuild-fixture style for browser proofs without Storybook.

Automated review (maintainer link)

This branch was successfully deployed

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

Labels

community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Touch hit-area measurement reads content-visibility-skipped descendants

1 participant