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

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

Open
3 tasks done
matinzd opened this issue Sep 14, 2019 · 31 comments

Comments

@matinzd
Copy link
Contributor

matinzd commented Sep 14, 2019

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 matinzd added the Bug label Sep 14, 2019
@matinzd matinzd changed the title FlatList automatically scrolls when data is too large in horizontal mode FlatList automatically scrolls to first when data is too large in horizontal mode Sep 14, 2019
@matinzd
Copy link
Contributor Author

matinzd commented Sep 16, 2019

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

@matinzd matinzd changed the title FlatList automatically scrolls to first when data is too large in horizontal mode [URGANT] [Android] FlatList automatically scrolls to first when data is too large in horizontal mode Sep 19, 2019
@matinzd matinzd changed the title [URGANT] [Android] FlatList automatically scrolls to first when data is too large in horizontal mode [URGENT] [Android] FlatList automatically scrolls to first when data is too large in horizontal mode Sep 19, 2019
@stale
Copy link

stale bot commented Jan 12, 2020

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 stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 12, 2020
@matinzd
Copy link
Contributor Author

matinzd commented Jan 13, 2020

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!

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 13, 2020
@matinzd matinzd changed the title [URGENT] [Android] FlatList automatically scrolls to first when data is too large in horizontal mode BUG - FlatList automatically scrolls to first when data is too large in horizontal mode (Android) Jan 13, 2020
@djhr
Copy link

djhr commented Mar 20, 2020

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

@matinzd
Copy link
Contributor Author

matinzd commented Mar 22, 2020 via email

@mohs3n71
Copy link

mohs3n71 commented Apr 11, 2020

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

@vinayp-go
Copy link

Any Update on this? Or any alternative approach?

@mm7mod
Copy link

mm7mod commented May 25, 2020

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

@fabOnReact
Copy link
Contributor

The issue should mention RTL in the title

Probably a duplicate of #19150

@praveens96
Copy link

praveens96 commented Jul 3, 2020

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

@stale
Copy link

stale bot commented Oct 4, 2020

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 stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 4, 2020
@matinzd
Copy link
Contributor Author

matinzd commented Oct 10, 2020

It has not fixed yet.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 10, 2020
@kartavyaparekh96
Copy link

Any update?

@lucascooelho
Copy link

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

@zohaib201
Copy link

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,
}}
/>

@matinzd matinzd changed the title BUG - FlatList automatically scrolls to first when data is too large in horizontal mode (Android) BUG - FlatList automatically scrolls to first when data is too large in horizontal mode RTL (Android) Jan 29, 2021
@emil45
Copy link

emil45 commented Mar 20, 2021

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

@lucascooelho
Copy link

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.

@matinzd
Copy link
Contributor Author

matinzd commented Jul 27, 2021

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.

@Noitham
Copy link

Noitham commented Sep 22, 2021

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

@aliraza-noon
Copy link

its really strange this is still a thing

@Chronostyle
Copy link

@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...

@matinzd
Copy link
Contributor Author

matinzd commented Jan 25, 2022

@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. 😂

@Kelvin-Lim-PKM
Copy link

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.

@matinzd
Copy link
Contributor Author

matinzd commented Jan 9, 2023

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 😅

@BStar098
Copy link

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

@dev-arson
Copy link

#37651
In rn-tester app this fix works

@cjhines
Copy link

cjhines commented Jun 29, 2023

Experiencing this on horizontal FlatList, even without RTL.

After 10 items the list goes back to the beginning

@Kaveh-ap
Copy link

Kaveh-ap commented Jul 16, 2023

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

Copy link

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 github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 13, 2024
@BStar098
Copy link

Has this bug been fixed?

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2024
@emxxm1
Copy link

emxxm1 commented Feb 22, 2024

In my case, I was using a custom component both for horizontal & vertical flat list,
<FlatList
data={data}
showsHorizontalScrollIndicator={false}
pagingEnabled={true}
horizontal={horizontal}
keyExtractor={(item, index) => key-${index}}
scrollEnabled={data?.length > 0}
initialNumToRender={3}
nestedScrollEnabled
onEndReachedThreshold={0.8}
initialScrollIndex={0}
onEndReached={() => { }}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => ...)}
/> .

        This line  pagingEnabled={true} was a cause in my scenario, as paging is being true for horizontal cases too.
        I just changed it to  pagingEnabled={!horizontal}
        Maybe it will help any of you guys having the same scenario as me.

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

No branches or pull requests