Repository navigation
refactor(core): the internal finger-scroll reader accepts a ref that names the document - #10883
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec b8e9ed3 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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]
|
/approve-spec b8e9ed3 |
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 internaluseFingerScrollaccepted 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):scrolleris nowRefObject<Element | Document | null> | Document, where it wasRefObject<Element | null> | Document.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.tsxpasses, including the new case.tsc, ESLint, Prettier andcheck:changesetspass.Scope