react-native icon indicating copy to clipboard operation
react-native copied to clipboard

BUG - FlatList automatically scrolls to first when data is too large in horizontal mode RTL (Android)

Open matinzd opened this issue 6 years ago • 32 comments

  • [x] Review the documentation: https://facebook.github.io/react-native

  • [x] Search for existing issues: https://github.com/facebook/react-native/issues

  • [x] Use the latest React Native release: https://github.com/facebook/react-native/releases

Environment

System:
    OS: macOS 10.15
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 448.96 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.61.2 => 0.61.2

React Native version: 0.61.2

Code

<FlatList
    style={{
        flexDirection: 'row',
        marginHorizontal: -wp('3%'),
        zIndex: 40
    }}
    initialNumToRender={10}
    data={this.state.data}
    horizontal={true}
    key={item => item.groupNo}
    keyExtractor={(item, index) => index.toString()}
    showsHorizontalScrollIndicator={false}
    showsVerticalScrollIndicator={false}
    ref={ref => (this.flatList = ref)}
    renderItem={({ item }) => (
        <GroupAyeItem item={item} />
    )}
/>

Steps To Reproduce

  1. Added some data to my FlatList
  2. Add horizontal={true} property to flatlist
  3. Set I18nManager.allowRTL(true)
  4. Set I18nManager.forceRTL(true)
  5. Make my renderItem component extends as PureComponent.
  6. Tested with Real Android Device and Emulator

As you see below when my app is running on RTL direction FlatList automatically scrolls to top/first of the list but LTR direction is OK!

RTL:

RTL_GIF

LTR:

LTR_GIF

UPDATE ON THIS ISSUE ! :
onScroll will get called rapidly in VirtualizedList.js:1443 when RTL is enabled without scrolling!

flatlist

But in LTR :
flatlist_ltr

matinzd avatar Sep 14 '19 10:09 matinzd

Any update on this issue?!?
I think this is same as #17540 and #19979

matinzd avatar Sep 16 '19 05:09 matinzd

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 a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

stale[bot] avatar Jan 12 '20 16:01 stale[bot]

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 a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

This issue does exist yet!

matinzd avatar Jan 13 '20 20:01 matinzd

Having similar issue with scrollview on android, when size changes (e.g. due keyboard open), the scrollview resets it's position

djhr avatar Mar 20 '20 09:03 djhr

I had this problem even if there is no resize!

On Fri, 20 Mar 2020, 12:53 djhr, [email protected] wrote:

Having similar issue with scrollview on android, when size changes (e.g. due keyboard open), the scrollview resets it's position

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/26436#issuecomment-601604119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5GCKOPCK4T6EXDNCMXS3DRIMYZZANCNFSM4IWWVM2Q .

matinzd avatar Mar 22 '20 06:03 matinzd

I have the same exact problem too and couldn't find any fix for it for me it happens when the length of data array is bigger than 19

mohs3n71 avatar Apr 11 '20 13:04 mohs3n71

Any Update on this? Or any alternative approach?

vinayp-go avatar Apr 27 '20 05:04 vinayp-go

yes facing the same issue, I have found multiple issues for the same error ... the strange thing is that this issue has been around for years now without a solution ....

any idea for a horizontal list views libraries out there that don't depend on the flat list ... I have found this library for vertical list: recyclerlistview and till now it is way way better than the buggy flatlist and performance is much better

mm7mod avatar May 25 '20 01:05 mm7mod

The issue should mention RTL in the title

Probably a duplicate of https://github.com/facebook/react-native/issues/19150

fabOnReact avatar May 25 '20 09:05 fabOnReact

even LTR has the issue in horizontal, iOS also facing this. I am on RN 0.62

praveens96 avatar Jul 03 '20 10:07 praveens96

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 a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

stale[bot] avatar Oct 04 '20 02:10 stale[bot]

It has not fixed yet.

matinzd avatar Oct 10 '20 11:10 matinzd

Any update?

kartavyaparekh96 avatar Nov 25 '20 08:11 kartavyaparekh96

I've been looking for any solution about this issue for days so far. I haven't found.

lucascooelho avatar Dec 04 '20 13:12 lucascooelho

You may follow this, https://stackoverflow.com/a/62066090/10464651 <FlatList ref={(ref) => { this.chatFlatList = ref; }} style={styles.flatList} data={this.state.items} renderItem={this._renderItem} maintainVisibleContentPosition={{ minIndexForVisible: 0, }} />

zohaib201 avatar Jan 05 '21 07:01 zohaib201

Any update? facing the same issue with Hebrew (RTL language). Maybe any workaround?

emil45 avatar Mar 20 '21 22:03 emil45

Any update? facing the same issue with Hebrew (RTL language). Maybe any workaround?

taka a look at this https://github.com/satya164/react-native-tab-view/issues/1068#issuecomment-783233062. It worked for me.

lucascooelho avatar May 04 '21 11:05 lucascooelho

Any update? facing the same issue with Hebrew (RTL language). Maybe any workaround?

taka a look at this satya164/react-native-tab-view#1068 (comment). It worked for me.

This is unrelated to the current issue.

matinzd avatar Jul 27 '21 09:07 matinzd

Facing the same issue here.. Tried both a FlatList & ScrollView, same issue. https://user-images.githubusercontent.com/32934478/134426408-9b4af234-2f96-4cdf-a52d-55574d48c96d.mov

Noitham avatar Sep 22 '21 21:09 Noitham

its really strange this is still a thing

aliraza-noon avatar Dec 26 '21 13:12 aliraza-noon

@matinzd hey, did you already find a solution for this bug?i also has the same issue just like you, for me it's from LTR not RTL on android...

Chronostyle avatar Jan 25 '22 16:01 Chronostyle

@matinzd hey, did you already find a solution for this bug?i also has the same issue just like you, for me it's from LTR not RTL on android...

No, my project is now dead but this issue still not resolved. 😂

matinzd avatar Jan 25 '22 16:01 matinzd

I had the same issue. For my case it was caused by getItemLayout() in FlatList. Not using getItemLayout() solved the issue for me. Maybe a correct/precise implementation (calculation of length and offset) of getItemLayout() function is needed.

Kelvin-Lim-PKM avatar Jan 09 '23 05:01 Kelvin-Lim-PKM

I had the same issue. For my case it was caused by getItemLayout() in FlatList. Not using getItemLayout() solved the issue for me. Maybe a correct/precise implementation (calculation of length and offset) of getItemLayout() function is needed.

But this was just happening on RTL. It should bahave the same way. Since then, I have changed 2 companies but this issue still exists 😅

matinzd avatar Jan 09 '23 05:01 matinzd

Yup, now I'm the one struggling with it haha

BStar098 avatar Apr 26 '23 13:04 BStar098

https://github.com/facebook/react-native/pull/37651 In rn-tester app this fix works

dev-arson avatar Jun 01 '23 07:06 dev-arson

Experiencing this on horizontal FlatList, even without RTL.

After 10 items the list goes back to the beginning

cjhines avatar Jun 29 '23 12:06 cjhines

I'm facing the same problem! I've tried FlashList as well, and unfortunately, it acts even weirder when RTL is true.

Kaveh-ap avatar Jul 16 '23 17:07 Kaveh-ap

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jan 13 '24 05:01 github-actions[bot]

Has this bug been fixed?

BStar098 avatar Jan 15 '24 14:01 BStar098