Skip to content

Commit d376a44

Browse files
danilobuergerfacebook-github-bot
authored andcommitted
Adjust scrollToLocation when using sticky section headers (#24735)
Summary: When using `scrollToLocation` together with `stickySectionHeadersEnabled` in a `SectionList`, the length of the section header is not accounted for when scrolling to any item except the header. [General] [Fixed] - Adjust scrollToLocation when using sticky section headers Pull Request resolved: #24735 Differential Revision: D15240953 Pulled By: cpojer fbshipit-source-id: fd7121d990c5b01533e456bdfa39bebf6245fa80
1 parent 509a07b commit d376a44

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Libraries/Lists/VirtualizedSectionList.js

+8
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,16 @@ class VirtualizedSectionList<
149149
for (let i = 0; i < params.sectionIndex; i++) {
150150
index += this.props.getItemCount(this.props.sections[i].data) + 2;
151151
}
152+
let viewOffset = 0;
153+
if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) {
154+
const frame = this._listRef._getFrameMetricsApprox(
155+
index - params.itemIndex,
156+
);
157+
viewOffset = frame.length;
158+
}
152159
const toIndexParams = {
153160
...params,
161+
viewOffset,
154162
index,
155163
};
156164
this._listRef.scrollToIndex(toIndexParams);

0 commit comments

Comments
 (0)