Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset (#58329) - #58329
Open
amroaltah wants to merge 1 commit into
Open
Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky header offset (#58329)#58329amroaltah wants to merge 1 commit into
amroaltah wants to merge 1 commit into
Conversation
…der offset (react#58329) Summary: `VirtualizedSectionList.scrollToLocation`, and `SectionList` through its wrapper, mapped `itemIndex` to the underlying flat list without skipping the section header. As a result, `itemIndex: 0` targeted the header and every other item was one row early. Sticky-header compensation was also skipped for the first item, allowing the header to obscure it. This change adds the header row to the flattened target index and always applies the sticky-header offset using the current section header metrics. The public API remains zero-based, but callers that compensated for the old behavior must remove that compensation. Migration: - Replace `itemIndex: n + 1` workarounds with `itemIndex: n`. - Replace `itemIndex: data.length` last-item workarounds with `itemIndex: data.length - 1`. Thanks to Marc Rousavy (mrousavy) for the diagnosis: react#50143 Changelog: [General][Breaking] - Fix `SectionList` and `VirtualizedSectionList` `scrollToLocation` to account for section headers and sticky headers correctly. Differential Revision: D118547738
amroaltah
force-pushed
the
fix-virtualizedsectionlist-scrolltolocation
branch
from
September 8, 2026 20:32
69206a9 to
a5bb9b2
Compare
|
@amroaltah has exported this pull request. If you are a Meta employee, you can view the originating Diff in 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:
VirtualizedSectionList.scrollToLocation, andSectionListthrough its wrapper, mappeditemIndexto the underlying flat list without skipping the section header. As a result,itemIndex: 0targeted the header and every other item was one row early. Sticky-header compensation was also skipped for the first item, allowing the header to obscure it.This change adds the header row to the flattened target index and always applies the sticky-header offset using the current section header metrics. The public API remains zero-based, but callers that compensated for the old behavior must remove that compensation.
Migration:
itemIndex: n + 1workarounds withitemIndex: n.itemIndex: data.lengthlast-item workarounds withitemIndex: data.length - 1.Thanks to Marc Rousavy (mrousavy) for the diagnosis: #50143
Changelog:
[General][Breaking] - Fix
SectionListandVirtualizedSectionListscrollToLocationto account for section headers and sticky headers correctly.Differential Revision: D118547738