facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.14k stars 24.32k forks source link

Inverted Flatlist not working when scrolled #44151

Closed WoLewicki closed 4 months ago

WoLewicki commented 6 months ago

Description

On new arch, when FlatList is inverted, after scrolling the elements don't fire their onPress since the information about their position must be calculated wrongly. There is probably a bug with this method: https://github.com/facebook/react-native/blob/ddc9bd1ff351f3259b7d90dcde7babcedbf2c155/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp#L69 when we invert the FlatList.

Steps to reproduce

  1. Scroll
  2. See that the onPress is not fired.

React Native Version

0.73.6

Affected Platforms

Runtime - Android Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

System:
  OS: macOS 14.3
  CPU: (12) arm64 Apple M3 Pro
  Memory: 83.02 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/.nvm/versions/node/v20.10.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v20.10.0/bin/npm
  Watchman:
    version: 2023.11.27.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/wojciechlewicki/.rvm/gems/ruby-3.2.1/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "26"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 32.1.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-29 | Google Play ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11567975
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2
    path: /opt/homebrew/opt/openjdk@18/bin/javac
  Ruby:
    version: 3.2.1
    path: /Users/wojciechlewicki/.rvm/rubies/ruby-3.2.1/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

None here

Reproducer

https://github.com/WoLewicki/reproducer-react-native/tree/%40wolewicki/flatlist-inverted

Screenshots and Videos

No response

roryabraham commented 6 months ago

@WoLewicki thanks for producing this minimal reproduction. Should we update the reproducer to use RN 0.74.0-rc.9 rather than 0.73.6 and see if it's still reproducible?

roryabraham commented 6 months ago

this is also reproducible in 0.74.0-rc.9: https://github.com/roryabraham/reproducer-react-native-scrollview-tap/tree/%40wolewicki/flatlist-inverted

cortinico commented 6 months ago

Thanks @WoLewicki and @roryabraham for providing a reproducer and verifying against 0.74.0

This is (sadly) as known issue. The root cause is that for inverted flatlist we use a transform which is sometimes causing problems with measurements on Fabric (resulting in missed clicks). I remember discussing this with a lot of folks (@sammy-SC @javache @kmagiera @tomekzaw et. al.)

We were already aware of this issue and it's higher up on our agenda to fix. We'll update more on this issue as we have actionable next steps.

WoLewicki commented 6 months ago

@kosmydel has just found a potential fix for the problem, he'll link the PR here when he makes one 🚀

kosmydel commented 6 months ago

Hey, here is a potential fix for this issue.

realsoelynn commented 4 months ago

PR is merged. https://github.com/facebook/react-native/commit/3753b7a0e78f8820e5f5150dd9bdf1b53145a7bd

Thanks everyone for your contribution 🥳