Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatlist scrollToIndex scrolls item all the way to the top of the list and produces whitespace #19080

Closed
3 tasks done
velevtzvetlin opened this issue May 1, 2018 · 11 comments
Closed
3 tasks done
Labels
Bug Component: FlatList Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@velevtzvetlin
Copy link

velevtzvetlin commented May 1, 2018

I am rendering a flatlist and on iOS, when scrolltoindex is called on a item that is close to the bottom of the list, it is pushed to the top and leaves whitespace below it. When you touch the list, it snaps back down. On android it works perfectly. I would like to add that get item layout is implemented.

Environment

Environment:
OS: macOS High Sierra 10.13.2
Node: 7.10.1
Yarn: Not Found
npm: 4.2.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: Not Found

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

Steps to Reproduce

Expected Behavior

Expected behavior is what happens on android, it will only scroll a item far enough to leave whatever is below it without any whitespace under the last item.

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

@velevtzvetlin
Copy link
Author

upgraded still same issue. There are items above the index that is scrolled to
screen shot 2018-05-11 at 4 10 17 pm

@scottmas
Copy link

scottmas commented Jun 26, 2018

Can confirm this is happening on React Native 55.4. And similar to the post, it only happens on ios.

I have to do some janky logic to offset the scroll position by the max number of rows that can be rendered at a time. Like

//Scroll to last item
let scrollIndex = data.length - 1; 

//Correct for the bug
const maxNumRows = Math.floor(windowHeight / ROW_HEIGHT);
if (data.length - scrollIndex < maxNumRows) {
  const diff = maxNumRows - (data.length - scrollIndex) - 2;
  scrollIndex = scrollIndex - diff;
}

@elicwhite
Copy link
Member

Is this related to this PR? #22769

@scottmas
Copy link

scottmas commented Jan 3, 2019

Yes, that PR appears as though it would fix it.

@elicwhite
Copy link
Member

Can you test it on your problem and verify?

@scottmas
Copy link

scottmas commented Jan 4, 2019

I think so. Is the RN build process complicated or can I just point my package.json at his forked repo?

@elicwhite
Copy link
Member

@bartolkaruza
Copy link

@scottmas Were you able to verify that the PR fixed your issue? You don't actually have to worry about building from source for iOS (that's Android specific), so you can just npm/yarn add the github link to that branch to test your change.

"react-native": "cabelitos/react-native#scrollFix"

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: FlatList Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants