question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FlatList] Horizontal FlatList can't scroll to rest of content when RTL is true for localization

See original GitHub issue

Description

Localizing for a Right-to-Left language, Farsi, causes ListViews to reverse in a way that the scrollview can’t scroll to the rest of the content. Here is a GIF of its behaviour -

rtl-scrollview

Reproduction

An ordinary horizontal Listview will suffice. See mine below.

<ListView
          dataSource={this.dataSource}
          renderRow={this._renderRow.bind(this)}
          contentContainerStyle={styles.scrollViewStyle}
          horizontal={true}
          showsHorizontalScrollIndicator={false}
          automaticallyAdjustContentInsets={true}
          removeClippedSubviews={true}
          enableEmptySections={true}
  />

const styles = {
scrollViewStyle: {
        justifyContent: 'flex-end',
        flexDirection: 'row',
        alignItems: 'center',
    }
}

https://gist.github.com/annelorraineuy/7998b0275ba2b255366a288bb87aca7a

Solution

Provide support for how to fix Listview when in RTL for localization.

Additional Information

  • React Native version: 0.39.2
  • Platform: Android (did not test on iOS)
  • Development Operating System: MacOS
  • Dev tools: Webstorm IDE and Chrome debugging.

Probably noteworthy to also say I’ve tried using https://github.com/exponent/react-native-invertible-scroll-view but I still can’t scroll to the rest of the content. It only looks reversed but the behaviour is the same.

Will appreciate any leads or advice : (

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
skmailcommented, Sep 12, 2017

I came up with this approach on small datasets, any issues with it?

I18nManager.allowRTL(true);
I18nManager.forceRTL(true);

const FlatListProps = (data = []) => {
    const props = {
        style: {},
        data: data
    };

    if (I18nManager.isRTL && Platform.OS === 'android') {
        props.style.flexDirection = 'row-reverse';
        props.data = props.data.reverse()
        props.inverted = true
    }

    return props
}
<FlatList
     horizontal={true}
     keyExtractor={(item, index) => index}
     renderItem={this.renderItem}
     {...FlatListProps(this.props.data)} />
2reactions
DanGDroidcommented, Nov 21, 2017

for large data(over 30 items) ListView nor FlatList do not function with RTL

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native FlatList horizontal mode not working at all
Turns out you can't render your own scroll component if you want to be able to dynamically change from horizontal to vertical or...
Read more >
React Native Flatlist Scrolling To Left And Right With ...
FlatList renders items lazily when they are about to appear and When true the scroll view bounces horizontally when it reaches the These...
Read more >
Optimizing Flatlist Configuration - React Native
Pros: Bigger windowSize will result in less chance of seeing blank space while scrolling. On the other hand, smaller windowSize will result in ......
Read more >
Vertical and Horizontal Scrolling in a SectionList/FlatList
The problem with just doing this is that we render the section's data both horizontally and vertically. Therefore we need to disable the ......
Read more >
react native flatlist horizontal paging - You.com
I am seeing an issue with using a TouchableOpacity 'button' to control horizontal scrolling of a FlatList . If I activate Remote Debugging...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found