question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SectionList] scrollToLocation scrolls past content on iOS

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.3 Node: 8.2.1 Yarn: 0.27.5 npm: 5.3.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: ^16.2.0 => 16.2.0 react-native: ^0.53.3 => 0.53.3

Steps to Reproduce

Implement a SectionList and use scrollToLocation to scroll to the last section.

Expected Behavior

It scrolls to the last section, while making sure it doesn’t scroll past the content. On Android this works as expected:

screen shot 2018-01-08 at 11 54 05

Actual Behavior

On iOS scrollToLocation scrolls to far:

img_362ddaf36c23-1

This also introduces some weird issues when the user starts scrolling from there on.

Reproducible Demo

https://snack.expo.io/HJgTyClEG

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
DannyvanderJagtcommented, Jul 21, 2018

Got the same issue on IOS. After fiddling around I found a temporary solution for my app:

this.sectionListRef.scrollToLocation({
	itemIndex: -1 , // IOS only
	sectionIndex: index,
})

After this the scrollToLocation works as expected. Let me know if this works for others too

1reaction
Jpuntcommented, Jul 10, 2018

This issue is still relevant to RN 0.55.4

https://snack.expo.io/@jpunt/scrolltolocation

Environment:
  OS: macOS High Sierra 10.13.5
  Node: 8.2.1
  Yarn: 1.5.1
  npm: 5.3.0
  Watchman: 4.9.0
  Xcode: Xcode 9.4.1 Build version 9F2000
  Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz => 0.55.4
Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - scrollToLocation to top for sectionList scrolls past top ...
ScrollToLocation to top for sectionList scrolls to blank page that past very top items. I just want to scroll to very top items,...
Read more >
SectionList - React Native
Internal state is not preserved when content scrolls out of the render window. Make sure all your data is captured in the item...
Read more >
Help with scrollToLocation in a large SectionList : r/reactnative
When they click on a letter it is meant to scroll and bring them to that section. Much like how the native Iphone...
Read more >
react-native-keyboard-aware-scroll-view - npm
A React Native ScrollView component that resizes when the keyboard appears.. Latest version: 0.9.5, last published: a year ago.
Read more >
Reactjs – Crash when doing scrollToLocation on SectionList ...
We have an edge case in our app. After the UI is rendered and the user tries to scroll to a section it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found