Skip to content

fix(dots): center the active section when the section list opens - #13

Merged
gfrancischini merged 2 commits into
mainfrom
fix/section-list-center-on-open
Nov 11, 2026
Merged

gfrancischini merged 2 commits into
mainfrom
fix/section-list-center-on-open

Conversation

@gfrancischini

@gfrancischini gfrancischini commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

The section list renders nothing while closed. The touch that opened it found no list to scroll, so the list opened at its top. Only a later touch, or a retry, centered the section. Rows past the first batch made it worse: scrollToIndex failed for them, and the failure was ignored.

 FastScrollSectionFullList.show(section)
-  if the list is mounted:
-    scrollToIndex(section)           // animated
-    retry in 1 s
+  sectionToCenter = section
+  centerPendingSection()             // not animated
+  retry in 1 s                       // animated, as before

+onContentSizeChange                  // each batch of rows laid out
+  centerPendingSection()

+centerPendingSection
+  scrollToIndex(sectionToCenter, animated: false)
+  succeeded? forget sectionToCenter

 onScrollToIndexFailed
-  ignore
+  once rows have a height: jump to averageRowHeight * index (renders the rows around it)

The first scrolls are not animated. On Android, an animated scroll started while the list is still laying out its rows did not move it. With the fix but an animated scroll, the list still opened at its top. This also applies while dragging the dots with the list open: the list now jumps to the section under the finger instead of animating to it. The retry a second later stays animated.

The backlog item is removed from docs/backlog.md.

Evidence

Unit tests. Two new tests: the first fails on main (no scroll at all), the second covers rows past the first batch. The existing centering test now expects the first scroll unanimated.

touch opens the list on Dairy, rows laid out      -> scrollTo({ y: 55, animated: false }), retry { y: 55 }
30 sections, open on Aisle 25, 10 rows laid out   -> jump to { y: 715 } (30px average)
  next batches laid out                           -> scrollTo({ y: 870, animated: false }) (exact)

yarn test (98 passed, 2 todo), yarn typecheck and yarn lint pass.

On a device. Android emulator (API 36), example app, categories screen, about 45 sections. Steps: scroll the list so the dots show, then tap a dot far down (around section 30).

  • Before: the list opens at the first section and moves to the tapped one about 0.4 s later.
  • After: the list opens centered on the tapped section, from its first frame.
Before (main) After (this branch)
The list opens on Bracelets / 18K Rose Gold, the first section, then scrolls to the tapped one. The list opens on the tapped section.

Frame by frame, 0.2 s apart from the tap (top: before, bottom: after):

Full-resolution recordings: before.mp4, after.mp4. They are on the pr-assets branch, which only holds PR media and is not meant to be merged.

Merge Danger

Door: two-way

The change only affects how the section list scrolls to its active row.

Blast Radius: section list scrolling

The visible change besides the fix: while the list is open, it now jumps to the section under the finger instead of animating there. The public props and handle are unchanged.

This PR and "keep the section list open while a finger rests on the dots" both change show() in FastScrollSectionFullList.tsx and add tests at the same place. Whichever merges second needs a small rebase.

🤖 Generated with Claude Code

gfrancischini added a commit that referenced this pull request Nov 9, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gfrancischini
gfrancischini requested a balanced review from Copilot November 9, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Pending section centering is not retried when rows are measured after the content-size notification, leaving the list at the top until the one-second retry.

1 open issue
What changed in this PR

This PR updates the dots component’s section list to center the active section when it opens, including sections beyond the initial rendered rows.

Changes:

  • Tracks pending centering and retries on content-size changes, with an estimated-offset fallback for unmeasured rows.
  • Adds opening and delayed-layout tests, and updates expectations for non-animated initial scrolling.
  • Removes the related backlog item and updates the scrolling description.
File Description
src/​FastScrollSectionDots/​FastScrollSectionFullList.tsx Adds pending centering, layout tracking, and failed-scroll recovery.
src/​FastScrollSectionDots/​__tests__/​FastScrollSectionDots.test.tsx Tests centering on opening and after additional rows are measured.
docs/​backlog.md Removes the centering backlog item and revises scrolling documentation.

Review effort: Balanced

}}
onLayout={onLayout}
onScrollToIndexFailed={onScrollToIndexFailed}
onContentSizeChange={centerPendingSection}
@gfrancischini
gfrancischini force-pushed the fix/section-list-center-on-open branch from 805e27d to 0d4016f Compare November 9, 2026 21:13
gfrancischini and others added 2 commits November 10, 2026 20:19
The section list renders nothing while closed, so the touch that opened
it found no list to scroll and the list opened at its top. Only a later
touch, or the retry a second later, centered the section.

The section to center now waits until the list has laid out its row,
and scrolls on each content size change until it does. A row past the
first batch is reached by jumping to where the average row height puts
it, which renders the rows around it. These scrolls are not animated:
on Android an animated scroll started while the list lays out its rows
does not move it. The retry a second later stays animated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The list can report its content size before it lays its rows out, and
laying them out need not change that size again. Centering then found no
row to estimate from and waited for the retry a second later. Try again
every 50 ms until a row is laid out, until that retry takes over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gfrancischini
gfrancischini force-pushed the fix/section-list-center-on-open branch from 0d4016f to ecf378e Compare November 11, 2026 02:46
@gfrancischini
gfrancischini merged commit c56ff00 into main Nov 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants