Skip to content

[RN] Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset - #58329

Open
amroaltah wants to merge 1 commit into
react:mainfrom
amroaltah:fix-virtualizedsectionlist-scrolltolocation
Open

[RN] Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset#58329
amroaltah wants to merge 1 commit into
react:mainfrom
amroaltah:fix-virtualizedsectionlist-scrolltolocation

Conversation

@amroaltah

Copy link
Copy Markdown

Summary: Fix scrollToLocation off-by-one and sticky header. See https://www.internalfb.com/intern/phabricator/D118547738

Thanks to Marc Rousavy #50143

Changelog: [General][Breaking] - Fix SectionList and VirtualizedSectionList scrollToLocation

Test Plan: js1 test 18 passed, arc lint clean

…y header offset

Summary:
VirtualizedSectionList.scrollToLocation incorrectly mapped itemIndex to the underlying flat list index. It used itemIndex directly instead of itemIndex + 1 to skip the section header, so itemIndex: 0 landed on the header and every other item was one row too early. It also only added the sticky-header viewOffset compensation when itemIndex > 0, so the first item was rendered under the sticky header.

This change adds the missing + 1 for the header row and makes the sticky-header offset unconditional, using the section header measured height (index - itemIndex - 1). This is a breaking behavioural fix with no type change.

Thanks to Marc Rousavy (mrousavy) for the diagnosis: react#50143

Changelog:
[General][Breaking] - Fix SectionList and VirtualizedSectionList scrollToLocation to correctly account for section headers and sticky headers.

Test Plan:
- js1 test xplat/js/react-native-github/packages/virtualized-lists/Lists/__tests__/VirtualizedSectionList-test.js — 18 passed
- arc lint clean

Differential Revision: https://www.internalfb.com/intern/phabricator/D118547738
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 4, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant