From c71b2ac62d5e48fdaedb4ff940e2bbc6ed65bb00 Mon Sep 17 00:00:00 2001 From: "Jules Sam. Randolph" Date: Fri, 19 Jul 2019 16:03:48 +0200 Subject: [PATCH] fix VirtualizedSectionList.scrollToSection ignoring viewOffset PR #24735 introduced commit d376a44 to handle sticky headers gracefully. But it missed taking into account user-provided viewOffset parameter, overwriting it. This is a straightforward change, adding the sticky header offset to the existing user provided viewOffset value. --- Libraries/Lists/VirtualizedSectionList.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index ebd12dfad57dc7..841aaca87433fc 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -143,17 +143,18 @@ class VirtualizedSectionList< itemIndex: number, sectionIndex: number, viewPosition?: number, + viewOffset?: number, }) { let index = params.itemIndex; for (let i = 0; i < params.sectionIndex; i++) { index += this.props.getItemCount(this.props.sections[i].data) + 2; } - let viewOffset = 0; + let viewOffset = params.viewOffset || 0; if (params.itemIndex > 0 && this.props.stickySectionHeadersEnabled) { const frame = this._listRef._getFrameMetricsApprox( index - params.itemIndex, ); - viewOffset = frame.length; + viewOffset = viewOffset + frame.length; } const toIndexParams = { ...params,