Commit 69206a9
Amro Altahtamouni
[RN] Fix VirtualizedSectionList.scrollToLocation off-by-one and sticky 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: #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/D1185477381 parent d44efb0 commit 69206a9
1 file changed
Lines changed: 3 additions & 3 deletions
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
0 commit comments