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

Scroll issue in horizontal flatlist in android (react native version 0.73.5) #43564

Open
nehab5889 opened this issue Mar 20, 2024 · 10 comments
Open
Labels
Component: FlatList Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Newer Patch Available Platform: Android Android applications.

Comments

@nehab5889
Copy link

nehab5889 commented Mar 20, 2024

Description

I am facing an issue in the scroll of the horizontal flatlist on android devices and simulators. Even if there is a single item in the flatlist, the user is able to scroll and the image remains on the right side after scroll until the user taps on it.
I started facing this issue after updating react native from version 0.70 to 0.73.5.

The code that is have written is:
<FlatList
horizontal={true}
data={props.data}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => renderImageList(item, index)}
/>

Please refer to the below recording to understand my issue better.

scroll.issue.mov

Any help on this will be highly appreciated.

Steps to reproduce

<FlatList
horizontal={true}
data={props.data}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => renderImageList(item, index)}
/>

React Native Version

0.73.5

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.1.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 161.58 MB / 16.00 GB
  Shell:
    version: 3.2.57
    path: /bin/bash
Binaries:
  Node:
    version: 18.14.2
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.10
    path: ~/.npm-global/bin/yarn
  npm:
    version: 9.6.0
    path: ~/.npm-global/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/nehabhandari/.rbenv/shims/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: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10227.8.2321.11479570
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/nehabhandari/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.5
    wanted: 0.73.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

info React Native v0.73.6 is now available (your project is running on v0.73.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.73.6
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.73.6
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos"

Stacktrace or Logs

-```


### Reproducer

-
### Screenshots and Videos

_No response_
Copy link

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.73.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@github-actions github-actions bot added Newer Patch Available Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Mar 20, 2024
Copy link

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@TommysG
Copy link

TommysG commented Mar 20, 2024

I've encountered a similar problem with the horizontal ScrollView. While I haven't experienced it on my Android 11 device, on later Android versions it seems to happen.

@jo7475
Copy link

jo7475 commented Mar 21, 2024

Hey i just ran into this issue my self on version 0.73.4, i gave the contentContainerStyle of the flat list a min width of "100%" and it seems to get the job done.

@nehab5889
Copy link
Author

@jo7475 It seems to work. Thank you!!

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Mar 21, 2024
@j-s-ott
Copy link

j-s-ott commented Mar 22, 2024

I think this is the same issue as #41492 and #36617. I've been able to reproduce it in an Android emulator, but not in a Snack unfortunately.

@CostasCF
Copy link

@jo7475 Hey Jo, thanks for the suggestion. However this does seem to disable the scroll entirely and if the items' size change dynamically, the user will not be able to scroll through the horizontal list.

@mannoeu
Copy link

mannoeu commented Apr 11, 2024

The same happened to me. I tested using react-native LTS 0.73.6 and when the list has only one element the behavior appears.

A curious fact is that I tested on different devices/Android versions using BrowserStack, only devices with Android 12+ showed the behavior.

In my case, adding flexGrow: 1 in contentContainerStyle solved

<ScrollView contentContainerStyle={{ flexGrow: 1 }} />

@Bardiamist
Copy link
Contributor

Just came to write that flexGrow: 1 works better than minWidth: '100%' but it already here 😊

@boiboif
Copy link

boiboif commented Apr 16, 2024

flexGrow: 1 solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: FlatList Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Newer Patch Available Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

8 participants