Skip to content

Flatlist scrolls to the opposite direction when content height changes #24011

@pinarol

Description

@pinarol

🐛 Bug Report

FlatList sometimes produces a scrolling glitch when we change the content. That means, scrolling goes to the opposite direction for a bit. We already had made an extra development to make scroll position follow the cursor so it is coming back to visible area. But still the first movement to the opposite direction is sth we don't directly do and it looks a bit odd.

This sometimes happens when we add new content, scrolling position goes down unnecessarily:

split-glitch-fast1

In slow motion:

split-glitch-slow1

This sometimes happen when we merge the content so the content height decreases, as noticed here scroll position goes down a bit when the merge happens

merge-glitch1

Some analysis:

when I comment out the method

- (CGPoint)calculateOffsetForContentSize:(CGSize)newContentSize
everything works fine, so maybe just being able to turn off the calculateOffsetForContentSize method call would solve this, but any other solutions and workarounds are also very appreciated.

To Reproduce

This repo can be checked out https://github.com/wordpress-mobile/gutenberg-mobile

  • cd to repo
  • yarn install
  • yarn start
  • yarn ios

to open the example app and try adding merging text inputs by erase/return buttons at some point it'll start to glitch.

Expected Behavior

Here is the expected behavior, no scrolling to the opposite side:

split-glitch-normal1

Code Example

You can refer to the repo https://github.com/wordpress-mobile/gutenberg-mobile and follow "To Reproduce" steps. Here's the exact place of the FlatList https://github.com/wordpress-mobile/gutenberg-mobile/blob/5f1a641637a8b26a8354982c8b2b61b39c1f6acb/src/components/keyboard-aware-flat-list.ios.js#L63

Environment

React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 427.82 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.12.0 - ~/.nvm/versions/node/v10.12.0/bin/node
Yarn: 1.10.1 - ~/.nvm/versions/node/v10.12.0/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.12.0/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 26, 27, 28
Build Tools: 26.0.2, 26.0.3, 27.0.3, 28.0.3
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.0 => 0.59.0
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions