Skip to content

refactor(core): the internal finger-scroll reader accepts a ref that names the document - #10883

Merged
cixzhang merged 1 commit into
mainfrom
fix/core-finger-scroll-document-ref
Nov 11, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/core-finger-scroll-document-ref

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #10883 → #10879

Maintainer impact

Lab's ChatVirtualizer, attached to the page's own scroller (document.scrollingElement), must watch the page's finger scrolls. That scroller's scroll events fire at the document, so the component's one live-scroller ref has to be able to name the document. Core's internal useFingerScroll accepted a ref to an element, or the document itself, but not a ref that names the document. This lets the ref name it. The stacked Lab fix uses it.

What changes

  • useFingerScroll(scroller): scroller is now RefObject<Element | Document | null> | Document, where it was RefObject<Element | null> | Document.
  • Runtime behavior is unchanged. The watch already treats the document as the page's scroller, and the hook attaches to whatever node the ref names after each commit.
  • A test reads a finger's page scroll through a ref that names the document: true while the finger scrolls, false after its scrollend.

This is an internal entry (@astryxdesign/core/internal/touch), limited by lint to Core and Lab, with no public API change.

Gesture-feel check

The type change alone changes no gesture. The new ref form is exercised on a phone by the stacked Lab fix's page-scroller story: a finger scroll on the page, with momentum, must not be fought by the list's scroll writes. The preview links are in the Lab pull request.

Evidence

  • packages/core/src/gestures/__tests__/useFingerScroll.test.tsx passes, including the new case.
  • Core tsc, ESLint, Prettier and check:changesets pass.

Scope

  • One internal type widening, with its test.
  • No public API change.
  • Public text contains no internal Meta context.

…names the document

useFingerScroll took a ref to an element, or the document for the page's
own scroll. A component whose scroller may be either (Lab's ChatVirtualizer
attached to document.scrollingElement, whose scroll events fire at the
document) holds both in one ref. The hook now accepts a ref whose current
names the document; the watch already treated the document as the page's
scroller, so behavior is unchanged. A test reads a finger's page scroll
through such a ref.
@vercel

vercel Bot commented Nov 9, 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 9, 2026 8:47pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 11:11 PM UTC

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 9, 2026
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec b8e9ed3

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b8e9ed3

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
lab/ChatVirtualizer 55.4 kB (0) · 144 B CSS (0) —
lab/NavigationScreen 82.6 kB (0) · 1.5 kB CSS (0) —
lab/NavigationStack 82.6 kB (0) · 1.5 kB CSS (0) —

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

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 36 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

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


Generated by PR Enrichment workflow | View full report

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

Approved pending CI: the required checks are still running on this head.

The change widens useFingerScroll's scroller parameter so a ref may hold the document; the hook stays on Core's internal touch entry, so the public API does not change. The new test reads a page finger scroll through such a ref and fails the type check against the old parameter type, so it pins the new contract.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 9, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 9, 2026 22:55
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b8e9ed3

@cixzhang
cixzhang merged commit 392750b into main Nov 11, 2026
129 checks passed
cixzhang added a commit that referenced this pull request Nov 11, 2026
@github-actions
github-actions Bot deleted the fix/core-finger-scroll-document-ref branch November 11, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — b8e9ed3a Deployed Nov 9, 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) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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.

1 participant