Skip to content
Permalink
Browse files

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
  • Loading branch information...
danilobuerger authored and facebook-github-bot committed May 7, 2019
1 parent 509a07b commit d376a444e318beabd8ebe9ccb41ffc300e12ea76
Showing with 8 additions and 0 deletions.
  1. +8 −0 Libraries/Lists/VirtualizedSectionList.js
@@ -149,8 +149,16 @@ class VirtualizedSectionList<
for (let i = 0; i < params.sectionIndex; i++) {
index += this.props.getItemCount(this.props.sections[i].data) + 2;
}
let viewOffset = 0;
if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) {
const frame = this._listRef._getFrameMetricsApprox(
index - params.itemIndex,
);
viewOffset = frame.length;
}
const toIndexParams = {
...params,
viewOffset,

This comment has been minimized.

Copy link
@jsamr

This comment has been minimized.

Copy link
@jsamr

This comment has been minimized.

Copy link
@danilobuerger

danilobuerger Jul 19, 2019

Author Contributor

@jsamr I don't understand why you are linking me about this. As you can see in my original commit, my order was different, allowing viewOffset to be overridden: 39dda67
I don't know why it was changed and then having my name attached to it.

index,
};
this._listRef.scrollToIndex(toIndexParams);

0 comments on commit d376a44

Please sign in to comment.
You can’t perform that action at this time.