Skip to content

fix(SnapPaging): a stop within half a step of the end is the end page - #10591

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:snap-paging-end-page
Nov 8, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:snap-paging-end-page

Conversation

@vjeux

@vjeux vjeux commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

User impact

With snap paging, a row ending just past an item's stop has two rests for one page. In the partial-last-page story 1 px narrower, a stop sits 1.37 px before the end. A Chromium Shift + wheel back from the end moves 1.37 px. Under {pages: 'item'} so does a flick back, and a flick onto the last page cuts its last item off by 1.37 px.

Problem and solution fit

  • Why? Stops merge only within half a pixel, so a stop 1.37 px before the end stays a page.
  • Why does it harm the task? A step back barely moves, and a rest can cut the last item off.
  • Why does it matter? The last page must rest where the row ends.

A stop within half its preceding step of the end now belongs to the end's page, which rests at the end. Native snap skips that stop's item, so wheels, keys and flicks rest on the same pages.

Expected behavior and authority

component:Carousel FR7: "the last page rests where the row ends". Amended here for the spec owners' stamp: FR7's stop sentence adds "except a stop within half its preceding step of the end, which joins the end's page". FR5 points to it, a state and a verification row describe it, and git diff -w shows only those rows and the separator.

Smallest restoration

  • snapPages returns the stops and the items whose stop the end's page takes.
  • The paging sets those items' scroll-snap-align to none, keeping each item's inline value and priority, and restores it once the stop splits from the end or the paging detaches.
  • The skip follows the stops at rest, at most once a frame, when the paging measures or items change (Core's shared observers). A change while held is written inside the hand-back, before snap type returns.

Evidence

  • Reproduction before the change: NOT-FOR-LANDING arm d5c979c (these tests on main) fails both unit cases and, 5 of 5 per engine, every browser case but WebKit's wheel and ArrowLeft: flicks and Chromium's keys and wheel rest at 411; the fifth item keeps start.
  • Result after the change: every case passes in both engines.
  • Unchanged path: a stop further from the end than half its step stays a page.
  • Mutation-sensitive proof: five NOT-FOR-LANDING commits, each removing one rule, listed under Testing.

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

  • core tsc 0; strict ESLint 0 and Prettier clean on the changed files; comment sentence lengths 0 over on the changed lines; check:changesets passes; check:knowledge reports the records aligned.
  • SnapPaging.test.tsx 16 of 16; on main, the 2 new cases fail. Carousel, SnapPaging, hooks and gestures unit suites: 96 files, 1,954 tests pass.
  • The 7 browser cases, 5 runs per engine, each tree on its own build. On main, the previous head and each mutant:
    • main: as in Evidence.
    • the previous head (e6139a8): in Chromium, the item added mid-settle rests at 514, not 411; the rest pass.
    • no end page (576b75f): as main.
    • no skip written (8addf91): the flicks pass; Chromium's wheel and ArrowLeft, both added-item cases and the resize case fail.
    • no re-derivation when the paging measures (5bee9d1): as no skip.
    • no child-list subscription (0dabcde): the item added at rest fails in both engines.
    • no write inside the hand-back (3b9ad56): the item added mid-settle fails in both engines.
    • this head: every case passes in both engines.
  • Interaction specs on a build of this head, ×3 per engine, 2 workers, no retries: Chromium 222 passed, 0 failed; WebKit 227 passed, 4 failed at a host load of 30, each stopped by the touch harness's pacing guards ("the page read a resting finger", "the page's own touch and pointer listeners took 44–58 ms").

Writing rubric results

R1 narration: none; the new state and verification row describe the system in the present tense.
R2 research: none in the record.
R3 evidence: the verification row names the tests and their inputs, not a change.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none added.

@vercel

vercel Bot commented Nov 7, 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 8, 2026 12:51am UTC

Request Review

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

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 1:09 AM UTC

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c655d60

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
Carousel 68.4 kB (+116 B) · 10.8 kB CSS (0) —

Package size: @astryxdesign/core 6.94 MB packed (+2.1 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 21 rows, core 39 rows; 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 7, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 6311fd2

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 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.

Changes requested: the end-page rule matches the owner-approved Split end rows and works for arrow keys and item-mode flicks in Chromium, but the native-snap skip goes stale when the row's items change.

  • After an item is added, or items resize, without the row itself resizing, the skipped item keeps scroll-snap-align: none, because skip runs only in measurePages (SnapPaging.ts:458-462). With an eighth item, ArrowRight from the fourth item then jumps to the sixth, and a Scroll right press settles on the fifth item and then jumps to the sixth. Please refresh the skip wherever fresh stops are read and when the children change, and add a test that adds an item.

Also worth a look: in headless Chromium the Shift + wheel case rests a full step back on main too, so an arrow-key case would pin the native-snap skip the changeset promises. FR7's first sentence could also name the new exception so that it agrees with the Split end row.

[Automated review]

@vjeux
vjeux force-pushed the snap-paging-end-page branch from 6311fd2 to e6139a8 Compare November 7, 2026 22:58
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 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.

Approval waits on an engineering owner's decision on the component:Carousel record changes at this head, and two code changes are needed.

This head writes the end-page exception into FR7's stop sentence and FR5 and adds the Split end and FR7 verification rows, and the earlier spec approval covered the previous head only. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), approving the record as written or asking for the Review checks row and the FR5/FR6 and FR7 stories verification rows to name the exception too.

Blocking:

  • When an item is added while the row settles, the hand-back scrolls and snaps before the catch-up rewrites the skip (SnapPaging.ts:497-503), so an item-mode flick from item 4 lands on 514 instead of 411 and skips item 5; please write the due skip inside the hand-back before scroll-snap-type comes back, and assert the rest offset in the mid-settle test.
  • The skip adds its own ResizeObserver and MutationObserver per carousel (SnapPaging.ts:510, :517) beside Core's shared observeResize, which the pager already uses on this row, and observeMutations; please subscribe through those, or extend the pager's track observer, as INV16 asks.

[Automated review]

@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/approve-spec e6139a8

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026
A row whose end sat 1.37 px past an item's stop had two rests for one
page. A flick or a wheel back from the end moved 1.37 px, and a flick
onto the last page could rest with the last item cut off. The end's
page is the page the end rounds to: a stop within half its step of the
end merges into it, and native snap skips that stop's item. So every
input rests where the row ends.

@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: the component:Carousel record changes are approved for this head, so what remains is two fixes in the snap-paging code.

  • When an item is added while the row settles, the hand-back scrolls and snaps before the catch-up rewrites the skip (SnapPaging.ts:497-503), so an item-mode flick from item 4 lands on 514 instead of 411 and skips item 5; please write the due skip inside the hand-back before scroll-snap-type comes back, and assert the rest offset in the mid-settle test.
  • The skip adds its own ResizeObserver and MutationObserver per carousel (SnapPaging.ts:510, :517) beside Core's shared observeResize, which the pager already uses on this row, and observeMutations; please subscribe through those, or extend the pager's track observer, as INV16 asks.

The end-page rule itself works as described in Chromium: ArrowLeft at the end now moves a whole item, and an item flick reaches the end.

[Automated review]

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec c655d60

@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: CI has not run on this head yet. This pull request is a draft from a fork, so every CI job skipped; once it is marked ready for review, a maintainer adds the ci:run label so CI runs.

The component:Carousel record changes carry an engineering owner's approval for this head, and both earlier requests are addressed: an item added while the row settles now rests on the fifth item, and the skip subscribes through Core's shared resize and mutation observers.

  • Non-blocking: every hand-back re-reads the stops, because the takeover's own measure marks the hold due (SnapPaging.ts:488); please name that reason in the comment above resnap.

[Automated review]

const stops = measured?.stops ?? track.stops();
// Native snap follows the new stops. The skip writes in a later
// frame, so this read stays ahead of any write.
resnap();

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.

Non-blocking (INV18): this resnap() also runs inside the takeover's own setOptions (line 465), before isMoving is set. Its frame lands in the hold and sets isResnapDue on every gesture, so each hand-back reads the row and every item's rect right after the translates clear: 8 reads per plain flick with no item change. If that re-derivation is meant to catch changes no observer reports (a gap or padding change), please say so in the comment above resnap. It now gives the reason only for a change during a hold. For example: "The takeover's measure also marks the hold due. So every hand-back re-derives the skip, which catches a change that no observer reports."

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 8, 2026
@vjeux
vjeux marked this pull request as ready for review November 8, 2026 02:01
@cixzhang
cixzhang merged commit 9218a45 into meta:main Nov 8, 2026
134 checks passed
@vjeux
vjeux deleted the snap-paging-end-page branch November 8, 2026 02:30

This branch was successfully deployed

1 active deployment
Preview — c655d60a Deployed Nov 8, 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.

2 participants