Skip to content

Commit

Permalink
Fixed regression in SectionList caused by #21577 not being able to sc…
Browse files Browse the repository at this point in the history
…roll to top on android (#24034)

Summary:
```
let index = params.itemIndex + 1;
```
to
```
let index = Platform.OS === 'ios' ? params.itemIndex : params.itemIndex - 1;
```
to fix an issue on iOS. Note however, how the sign for non iOS changed from `+` to `-` causing a crash on Android when trying to scroll to index 0 as that will be evaluated to -1 instead of 1 and thus be out of bounds.

[Android] [Fixed] - Fixed regression in SectionList caused by #21577 not being able to scroll to top on android
Pull Request resolved: #24034

Differential Revision: D14520796

Pulled By: cpojer

fbshipit-source-id: bb49619f49752fd3f343ef3b7bf1b86ac48af7f8
  • Loading branch information
danilobuerger authored and facebook-github-bot committed Mar 19, 2019
1 parent 0827184 commit 8fa116c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
sectionIndex: number,
viewPosition?: number,
}) {
let index = Platform.OS === 'ios' ? params.itemIndex : params.itemIndex - 1;
let index = Platform.OS === 'ios' ? params.itemIndex : params.itemIndex + 1;
for (let ii = 0; ii < params.sectionIndex; ii++) {
index += this.props.sections[ii].data.length + 2;
}
Expand Down

0 comments on commit 8fa116c

Please sign in to comment.