Skip to content

fix(dots): stop the section list centering a section the app removed - #19

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

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

Conversation

@gfrancischini

Copy link
Copy Markdown
Owner

Problem

After a touch on the dots, the section list centers the touched section again in two places:

  • the retry one second after show();
  • each content size change while the section is still waiting to be centered (new since 0.3.4).

Both reuse the section from show(). If the app passes fewer sections in the meantime, scrollToIndex gets an index past the last row and throws scrollToIndex out of range from a timer or an event handler. That is a fatal JS error, in release builds too.

The second path stays open for as long as the list is open (3 s after the lift). On the New Architecture the list reports each batch's content size before it lays those rows out, so when the touched row is in the last batch, its last centering attempt misses and the section stays pending. A tap on one of the last dots of a list with more than 10 sections is enough.

An app that unmounts the dots while it reloads (for example behind a loading view) never hits this.

Fix

centerSection centers a kept section only while the row at its position still has the same list index. Otherwise it does nothing, which also clears the pending section. An app that passes an equal new array on each render keeps its centering.

Device check

Example app, ReplaceSections screen (12 sections), Android emulator, Expo SDK 52 (Reanimated 3, New Architecture): a quick tap on the last dot, then "Only 1–4" about 1.5 s later, while the section list is open.

Before After
Uncaught Error: scrollToIndex out of range: requested index 11 is out of 0 to 3, thrown from centerPendingSection The list filters to 4 sections, no error

Videos: before.mp4, after.mp4

Tests

Two new tests in the dots suite, one per path, both failing with the invariant before the fix. The pending one fires the list's events in the New Architecture order. yarn test, yarn typecheck and yarn lint pass.

Also in this PR

A separate docs: commit with the findings of a review of main since 0.3.4 (backlog), and corrections to CLAUDE.md, README.md, CONTRIBUTING.md and docs/unit-testing.md that had gone stale. The fix commit then removes this bug from the backlog.

🤖 Generated with Claude Code

gfrancischini and others added 2 commits November 11, 2026 11:43
- backlog: the next release's checklist, five bugs, a cleanup list and a
  proposal found reviewing main since 0.3.4; line numbers moved to c56ff00
  and a resolved item dropped.
- CLAUDE.md: the list wrapper never calls the indicator's handle, the app
  does not clamp the offset, and handles avoid JS reads of shared values.
- README: the install command, the peer dependencies, and an indicator
  example that works with FlashList v2.
- CONTRIBUTING: yarn bootstrap, the Expo Go example, and no git hooks.
- unit-testing: yarn typecheck runs twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The section list centers the touched section again after show(): a second
later, and on each content size change while the section is pending. Both
kept the section from show(), so after the app passed fewer sections,
scrollToIndex got an index past the last row and threw "scrollToIndex out
of range" from a timer or an event handler, a fatal JS error.

The pending one can last as long as the list is open: on the New
Architecture the list reports each batch's size before laying its rows out,
so a section in the last batch misses its last chance to be centered.

A kept section is now centered only while the row at its position still has
its list index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

🟢 Approval recommended

There are no active review issues for the stale-section centering fix.

No open issues 🎉

What changed in this PR

Prevents the dots’ section list from attempting to center a removed section after the app replaces its section data, avoiding an out-of-range scroll error.

Changes:

  • Checks the current section’s position and list index before centering, while preserving centering for equivalent replacement arrays.
  • Adds regression tests for the one-second retry and pending content-size-change paths.
  • Refreshes usage, development, testing, and backlog documentation.
File Description
src/​FastScrollSectionDots/​FastScrollSectionFullList.tsx Guards centering against stale section data.
src/​FastScrollSectionDots/​__tests__/​FastScrollSectionDots.test.tsx Tests section removal before delayed and pending centering attempts.
README.md Corrects installation, lists peer dependencies, and updates scroll-percentage integration.
docs/​unit-testing.md Clarifies the two typechecking passes and their coverage.
docs/​backlog.md Updates outstanding issues, release checks, and cleanup proposals.
CONTRIBUTING.md Refreshes setup, example app, hooks, and CI guidance.
CLAUDE.md Clarifies production usage and performance constraints for imperative handles.

Review effort: Balanced

@gfrancischini
gfrancischini merged commit 48c8405 into main Nov 11, 2026
4 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