[RN] Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset - #58329
Open
amroaltah wants to merge 1 commit into
Open
[RN] Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset#58329amroaltah wants to merge 1 commit into
amroaltah wants to merge 1 commit into
Conversation
…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
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.
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