Repository navigation
fix(dots): stop the section list centering a section the app removed - #19
Merged
Merged
Conversation
- 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>
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a touch on the dots, the section list centers the touched section again in two places:
show();Both reuse the section from
show(). If the app passes fewer sections in the meantime,scrollToIndexgets an index past the last row and throwsscrollToIndex out of rangefrom 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
centerSectioncenters 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.
Uncaught Error: scrollToIndex out of range: requested index 11 is out of 0 to 3, thrown fromcenterPendingSectionVideos: 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 typecheckandyarn lintpass.Also in this PR
A separate
docs:commit with the findings of a review ofmainsince 0.3.4 (backlog), and corrections toCLAUDE.md,README.md,CONTRIBUTING.mdanddocs/unit-testing.mdthat had gone stale. The fix commit then removes this bug from the backlog.🤖 Generated with Claude Code