Skip to content

ScrollView weird behaviour when there are less items #42874

Closed

Description

@shreyanshgoel9

Description

When the scrollview container is bigger than total item width, on scroll the items start sticking on right on android.
Tested on physical device as well

Screen.Recording.2024-02-05.at.8.20.01.PM.mov

Steps to reproduce

  1. Installed React Native macOs, android simulator

  2. Write this code
    <ScrollView horizontal={true} style={{backgroundColor: 'green'}}> <View style={{ height: 40, width: 50, marginRight: 20, backgroundColor: 'red', }} /> <View style={{ height: 40, width: 50, marginRight: 20, backgroundColor: 'red', }} /> </ScrollView>

  3. Scroll horizontal to reproduce

React Native Version

0.73.3

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.1.2
  CPU: (8) arm64 Apple M1 Pro
  Memory: 87.98 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.12.1
    path: ~/.nvm/versions/node/v18.12.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.12.1/bin/yarn
  npm:
    version: 8.19.2
    path: ~/.nvm/versions/node/v18.12.1/bin/npm
  Watchman:
    version: 2023.08.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.2
    path: /opt/homebrew/opt/ruby/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.2
    path: /opt/homebrew/opt/openjdk/bin/javac
  Ruby:
    version: 3.2.2
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.3
    wanted: 0.73.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

-

Reproducer

snack.expo.dev/@uvrubel/rn-scrollview-horizontal

Screenshots and Videos

No response

Activity

  1. added
    Needs: Repro
    on Feb 5, 2024
  2. github-actions commented on Feb 5, 2024

    @github-actions
    ⚠️ 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.
  3. added
    Needs: Attention
    and removed on Feb 5, 2024
  4. Myst1024 commented on Feb 13, 2024

    @Myst1024

    Running into the same issue, using React Native 0.73.4. I have only been able to reproduce on physical Android devices.

  5. RakaDoank commented on Feb 16, 2024

    @RakaDoank
    Contributor

    I also have this issue. I can reproduce this in physical Android device (API 33) and Android simulator (API 34). So far, no problem on iOS simulator.

    I actually wanted to write this earlier. I remember i get this issue since i upgraded the RN to 0.73.0 from 0.72.7, until now currently on 0.73.4.

  6. kemplaw commented on Feb 17, 2024

    @kemplaw

    Running into the same issue, using React Native 0.72.10.

  7. ulyavrubel commented on Feb 27, 2024

    @ulyavrubel

    Running into the same issue, using React Native 0.73.4. Reproducible on Android only

    Steps to Reproduce

         <ScrollView horizontal>
           ...
          </ScrollView>
    

    Demo

    https://snack.expo.dev/@uvrubel/rn-scrollview-horizontal

    screen-20240227-111557.mp4
  8. added
    Issue: Author Provided Repro
    and removed
    Needs: Repro
    on Mar 5, 2024
  9. Titozzz commented on Mar 12, 2024

    @Titozzz
    Collaborator

    Can confirm this is not something that was here before (but cannot easily bisect).
    I can reproduce on 0.73.2 and 0.73.6

  10. 8 remaining items

  11. Titozzz commented on Mar 18, 2024

    @Titozzz
    Collaborator
  12. Titozzz commented on Mar 18, 2024

    @Titozzz
    Collaborator

    This is the line that breaks it for me 30c7e9d#diff-067e69cd88e616e9605533a4be612685b607a7d1cd29f854ee77d713113cb170R612-R614.

    (Verified with breakpoints)

  13. Regin99 commented on Mar 18, 2024

    @Regin99

    Yep you are using prefab probably! https://reactnative.dev/contributing/how-to-build-from-source#update-your-project-to-build-from-source Did you do that ?

    Yeah, my mistake. I'm forgot bout prefabs. Thank you

  14. hjun555 commented on Mar 21, 2024

    @hjun555

    same issue here, any solutions?

  15. Regin99 commented on Mar 21, 2024

    @Regin99

    same issue here, any solutions?

    Look above

  16. baez97 commented on Apr 15, 2024

    @baez97

    In case someone needs a fix without upgrading, setting contentContainerStyle to full width worked for me

    <ScrollView horizontal contentContainerStyle={{ width: "100%" }}>
  17. RobinBobin commented on May 2, 2024

    @RobinBobin

    Was it fixed in both 0.73 and 0.74? What are the versions, please?
    I still see this bug in 0.73.4.

  18. NickGerleman commented on May 2, 2024

    @NickGerleman
    Contributor

    Was it fixed in both 0.73 and 0.74? What are the versions, please? I still see this bug in 0.73.4.

    Available in 0.73.7+

  19. Arjun059 commented on Oct 29, 2024

    @Arjun059

    Quick Fix;
    contentContainerStyle={{flexGrow: 1}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Component: ScrollViewIssue: Author Provided ReproNeeds: Attention

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions