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

Horizontal ScrollView Resets Scroll Position (Android, RTL) #19979

Closed
3 tasks done
FuadBalashov opened this issue Jun 29, 2018 · 8 comments
Closed
3 tasks done

Horizontal ScrollView Resets Scroll Position (Android, RTL) #19979

FuadBalashov opened this issue Jun 29, 2018 · 8 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@FuadBalashov
Copy link

FuadBalashov commented Jun 29, 2018

Environment

  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.3
      CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
      Memory: 43.51 MB / 16.00 GB
      Shell: 4.4.12 - /usr/local/bin/bash
    Binaries:
      Node: 9.3.0 - /usr/local/bin/node
      Yarn: 1.3.2 - /usr/local/bin/yarn
      npm: 5.6.0 - /usr/local/bin/npm
      Watchman: 4.7.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
      Android SDK:
        Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 27.0.3
        API Levels: 19, 21, 22, 23, 24, 25, 26, 27
    IDEs:
      Android Studio: 2.3 AI-162.4069837
      Xcode: 9.2/9C40b - /usr/bin/xcodebuild
    npmPackages:
      react: 16.3.1 => 16.3.1
      react-native: 0.56.0-rc.4 => 0.56.0-rc.4
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

Horizontal ScrollViews reset their scroll position when their content size changes on Android in RTL.

That description is a mouthful so here is a gif showing the problem:

android rtl scroll bug

Reproducible Demo

Here is a snack from expo made by @megantracy93 https://snack.expo.io/@meganltracy/scrollview-scrolltoend-rtl-issue

Steps to Reproduce:

  • Create a UI with a horizontal scroll view
  • Introduce an event handler that adds content to the scroll view (eg a button that adds views to the scroll view.
  • Change the device locale to RTL (Arabic) OR force rtl on the ui:
 componentWillMount() {
    I18nManager.forceRTL(true);
  }
  • Scroll the horizontal scroll view to its end (left)
  • Trigger the event handler causing the contents of the scroll view to grow

Observed

  • The horizontal scroll position is set to the start (right side) of the view.

Expected

  • The horizontal scroll position should be maintained

Additional Info

From some debugging, we think ReactHorizontalScrollContainerView is likely the class which is responsible for positioning the horizontal ScrollView onLayout. That method gets called whenever the size of the contents change and resets the scroll position of the view. Instead, it should be setting it back to where it was before.

@react-native-bot react-native-bot added the Platform: Android Android applications. label Jun 29, 2018
facebook-github-bot pushed a commit that referenced this issue Jul 20, 2018
Summary: Fix the calculation of offsetX in onLayout (ReactHorizontalScrollContainerView.java) that re-positions the updated layout. A private instance variable (oldWidth) is added in order to track the width difference between consecutive updates. (Issue report: #19979)

Reviewed By: mdvacca

Differential Revision: D8772780

fbshipit-source-id: 969dcead550f4a3d24d06416b63d960492b7a124
@stale
Copy link

stale bot commented Sep 27, 2018

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 "For Discussion" or "Good first issue" 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 Sep 27, 2018
@rikur
Copy link

rikur commented Sep 29, 2018

Same problem with a ScrollView that has inverted property set.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 29, 2018
@Majid110
Copy link

Same problem for me!

@stale
Copy link

stale bot commented Jan 16, 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 "For Discussion" or "Good first issue" 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 Jan 16, 2019
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 26, 2019
@hramos hramos removed the Bug Report label Feb 6, 2019
@FadiAboMsalam
Copy link

can anyone verify that the fix in 0.58.6 commit #23233 did the fix ?

@ferrannp
Copy link
Contributor

Hello there 👋

I tried this on 0.59.x with the code you provided and it seems to be fixed. But please, if it's actually still an issue with 0.59 please comment below and we can reopen it 😊

@hemedani
Copy link

I have the same problem
in horizontal scroll view content sticks to the left side even when set contentContainerStyle={{ flexDirection: "row-reverse" }}

@matinzd
Copy link
Contributor

matinzd commented Oct 14, 2019

#23233

No I did not fix that!

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants