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

0.59.0-rc.0 Flatlist inverted horizontal #23453

Closed
tamirrab opened this issue Feb 14, 2019 · 4 comments
Closed

0.59.0-rc.0 Flatlist inverted horizontal #23453

tamirrab opened this issue Feb 14, 2019 · 4 comments

Comments

@tamirrab
Copy link

tamirrab commented Feb 14, 2019

🐛 Bug Report

0.59.0-rc.0 Flatlist inverted horizontal with ListFooterComponent or ListHeaderComponent:
when data is empty array and ListFooterComponent or ListHeaderComponent rendering component - the component show on left instead of right.
when adding data - the ListFooterComponent or ListHeaderComponent is ok.

The bug is on iOS and Android.
The bug not happened on 0.58.4 version

Code Example

Code:

const data = []; // The ListFooterComponent or ListHeaderComponent Is on the right
// data = ["test"]; // The ListFooterComponent or ListHeaderComponent Is on the left = OK
<FlatList
  data={data}
  keyExtractor={item => item}
  ListFooterComponent={<View
      style={{
          backgroundColor: "#D6D6D6",
          paddingVertical: 6,
          marginVertical: 6,
          borderRadius: 20,
          alignItems: 'center',
          paddingHorizontal: 15
      }}>
      <Text>{"+"}</Text>
  </View>}
  ListHeaderComponent={<View
      style={{
          backgroundColor: "#D6D6D6",
          paddingVertical: 6,
          marginVertical: 6,
          borderRadius: 20,
          alignItems: 'center',
          paddingHorizontal: 15
      }}>
      <Text>{"+"}</Text>
  </View>}
  inverted
  horizontal
  renderItem={({item, index}) => {
    return <View style={{justifyContent: 'center'}}>
        <Text>{"Test"}</Text>
    </View>
  }}/>

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 100.43 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v8.11.4/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 26, 27, 28
Build Tools: 27.0.3, 28.0.2, 28.0.3
System Images: android-24 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.1 => 16.8.1
react-native: 0.59.0-rc.0 => 0.59.0-rc.0
npmGlobalPackages:
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7

@react-native-bot

This comment has been minimized.

@tamirrab

This comment has been minimized.

@hramos

This comment has been minimized.

@kelset
Copy link
Contributor

kelset commented Mar 19, 2019

👋 there.

I just tested the code on RN 0.59 and this issue is still present: I actually investigated it a bit further and noticed that, by changing the code into:

import React, { Component } from 'react';
import { FlatList, StyleSheet, Text, View } from 'react-native';

const data = []; // The ListFooterComponent or ListHeaderComponent Is on the right
// const data = ['test']; // The ListFooterComponent or ListHeaderComponent Is on the left = OK

export default class App extends Component<> {
  render() {
    return (
      <View style={styles.container}>
        <FlatList
          data={data}
          keyExtractor={item => item}
          ListFooterComponent={
            <View
              style={{
                backgroundColor: '#D6D6D6',
                paddingVertical: 6,
                marginVertical: 6,
                borderRadius: 20,
                alignItems: 'center',
                paddingHorizontal: 15
              }}
            >
              <Text>{'Footer'}</Text>
            </View>
          }
          ListHeaderComponent={
            <View
              style={{
                backgroundColor: '#D6D6D6',
                paddingVertical: 6,
                marginVertical: 6,
                borderRadius: 20,
                alignItems: 'center',
                paddingHorizontal: 15
              }}
            >
              <Text>{'HEADER'}</Text>
            </View>
          }
          inverted
          horizontal
          renderItem={({ item, index }) => {
            return (
              <View style={{ justifyContent: 'center' }}>
                <Text>{'Test'}</Text>
              </View>
            );
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
    paddingTop: 40
  }
});

It becomes more clear that when there is no data this happens:

Screenshot 2019-03-19 at 16 12 51

Meaning, when there are no data it seems that the list "skips" an invert. Probably a temp workaround is to never have a 'really' empty data...? And handle the empty item state?

We'll look more into this in the next few months

kelset pushed a commit that referenced this issue Mar 29, 2019
…zedList when it's inverted (#24167)

Summary:
Fixes #23453
Fixes #21196

Basically, changes made in #21496 currently breaks behavior of `<VirtualizedList />`  and any components that are based on it (`<SectionList />, <FlatList />`). This PR solves both issues listed above.

Visual confirmation of the resolved issue:

**Vertical, not inverted, not empty**
![image](https://user-images.githubusercontent.com/7837457/55076839-b005d700-5096-11e9-91de-090934cb0129.png)

**Vertical, not inverted, empty**
![image](https://user-images.githubusercontent.com/7837457/55076971-fb1fea00-5096-11e9-8d73-5a2d86275da8.png)

**Vertical, inverted, not empty**
![image](https://user-images.githubusercontent.com/7837457/55077042-23a7e400-5097-11e9-911f-9dad4d48a578.png)

**Vertical, inverted, empty**
![image](https://user-images.githubusercontent.com/7837457/55079957-87351000-509d-11e9-8f1c-b7134f1f43f9.png)

**Horizontal, not inverted, not empty**
![image](https://user-images.githubusercontent.com/7837457/55077118-44703980-5097-11e9-94e9-e33d4af436ee.png)

**Horizontal, not inverted, empty**
![image](https://user-images.githubusercontent.com/7837457/55077150-52be5580-5097-11e9-9d43-7cb4e983167e.png)

**Horizontal, inverted, not empty**
![image](https://user-images.githubusercontent.com/7837457/55077183-623d9e80-5097-11e9-9e8a-1b2468c7b3a9.png)

**Horizontal, inverted, empty**
![image](https://user-images.githubusercontent.com/7837457/55080033-af247380-509d-11e9-90ae-1ff656d46dd1.png)

[General] [Fixed] - Fixed VirtualizedList, SectionList and FlatList behavior on rendering list headers with inverted prop and zero items
Pull Request resolved: #24167

Differential Revision: D14642345

Pulled By: cpojer

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

Successfully merging a pull request may close this issue.

4 participants