Skip to content

Commit

Permalink
Adjust scrollToLocation when using sticky section headers (#24735)
Browse files Browse the repository at this point in the history
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 d376a44
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Libraries/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

jsamr Jul 19, 2019

@danilobuerger I'm writing a fix.

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);
Expand Down

0 comments on commit d376a44

Please sign in to comment.