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

[SectionList][inverted] SectionSeparatorComponent displays in wrong places with inverted list #18943

Closed
3 tasks done
terrysahaidak opened this issue Apr 19, 2018 · 13 comments
Closed
3 tasks done
Labels
Bug Component: SectionList Priority: Low Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@terrysahaidak
Copy link

Environment

Environment:
OS: macOS High Sierra 10.13.1
Node: 8.6.0
Yarn: 1.5.1
npm: 4.6.1
Watchman: 4.9.0
Xcode: Xcode 9.0.1 Build version 9A1004
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Steps to Reproduce

Clone this repository and run it via react-native run-ios.
Observe the section separators are in wrong (randomly?) places.

Expected Behavior

The section separators should be right after the sections and section headers (like the non-inverted section list does).

I've used the same code as below but without inverted prop.

Expected gif:

kapture 2018-04-19 at 13 23 53

Actual Behavior

The section separator components are in wrong places in the list if the list is inverted. For a non-inverted list, it works as expected.

Sample code:

export default class App extends React.Component {
  render() {
    return (
      <View style={s.container}>
        <SectionList
          inverted
          sections={mock.sections}
          maxToRenderPerBatch={10}
          initialNumToRender={10}
          style={{ flex: 1 }}
          keyExtractor={(item) => item.messageId}
          renderSectionHeader={sectionProps => (
            <SectionHeader
              {...sectionProps}
            />
          )}
          renderItem={({ item }) => (
            <ListItem
              item={item}
            />
          )}
          SectionSeparatorComponent={Separator}
          ItemSeparatorComponent={ItemSeparator}
        />
        />
      </View>
    );
  }
}

const Separator = ({ big }) => (
  <View style={[s.separatorContainer, big && s.separatorBig]} />
);

const s = StyleSheet.create({
  container: {
    marginTop: 24,
    flex: 1,
    backgroundColor: 'white',
  },
  sectionContainer: {
    // height: 16,
    marginTop: 8,
    marginBottom: 16,
    backgroundColor: '#b4c5ff',
    borderRadius: 16,
    alignSelf: 'center',
    paddingHorizontal: 8,
    paddingVertical: 4,
  },
  separatorContainer: {
    height: 8,
    backgroundColor: 'gray',
    borderBottomWidth: 1,
    borderTopWidth: 1,
    borderBottomColor: 'blue',
    borderTopColor: 'blue',
  },
});

Problem Gif:

kapture 2018-04-19 at 13 21 10

@stale
Copy link

stale bot commented Jul 18, 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 Jul 18, 2018
@terrysahaidak
Copy link
Author

terrysahaidak commented Jul 18, 2018

Unfortunately, the issue still exists in the latest react native 56, so please don't close:
kapture_2018-07-18_at_16 20 45

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

try stickySectionHeadersEnabled={false}

@terrysahaidak
Copy link
Author

terrysahaidak commented Aug 8, 2018

@yanisakli Just tried it out with stickySectionHeaderEnabled={false}.
Nothing has changed.
The issue is about gray with blue borders blocks. Here how it should be (it works well without inverted prop):
image

And here is with inverted.
image

@earle
Copy link

earle commented Sep 5, 2018

To clarify the issue here: The section headers need to render before the section items when the SectionList is inverted -- currently when the SectionList is reversed the section headers are placed after each section

@nastynaz
Copy link

Any updates on this? I'm still getting this issue on the latest version of react native.

@terrysahaidak
Copy link
Author

@nastynaz I did implement my own section-list using flatlist and conditional rendering of the current item, poor performance but at least it works.

@stale
Copy link

stale bot commented Aug 2, 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 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 Aug 2, 2019
@terrysahaidak
Copy link
Author

terrysahaidak commented Aug 2, 2019

This hasn't been 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 Aug 2, 2019
dy93 added a commit to mediot-inc/react-native that referenced this issue Oct 21, 2019
…ponent should displays in correct place with inverted list
dy93 added a commit to mediot-inc/react-native that referenced this issue Oct 21, 2019
…ponent should displays in correct place with inverted list
dy93 added a commit to mediot-inc/react-native that referenced this issue Oct 21, 2019
facebook-github-bot pushed a commit that referenced this issue Oct 28, 2019
#26933)

Summary:
SectionSeparatorComponent and ItemSeparatorComponent should displays in the correct place with an inverted list

This PR fix issue #18943
Currently, when using SectionSeparatorComponent and ItemSeparatorComponent with an inverted SectionList, the separators will display at the wrong place.
Please see issue #18943 for more information.

## Changelog
[General] [Fixed] - Fix separators displays in wrong places with the inverted list
Pull Request resolved: #26933

Test Plan:
before this fix, the following code will result in following screenshots:
```
import React from 'react';
import { StyleSheet, Text, SectionList, SafeAreaView } from 'react-native';

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <SectionList
        style={{ width: '100%' }}
        sections={[
          {
            data: ['item 1', 'item 2', 'item 3', 'item 4', 'item 5', 'item 6', 'item 7']
          }
        ]}
        renderItem={({ item }) => <Text style={{ fontSize: 18, backgroundColor: 'greenyellow', width: '100%' }}>{item}</Text>}
        inverted
        SectionSeparatorComponent={() => <Text style={{ fontSize: 28, backgroundColor: 'fuchsia', width: '100%' }}>section separator</Text>}
        ItemSeparatorComponent={() => <Text style={{ fontSize: 12, backgroundColor: 'gold', width: '100%' }}>item separator</Text>}
        renderSectionHeader={()=><Text style={{ fontSize: 38, backgroundColor: 'lightpink', width: '100%' }}>section header</Text>}
        renderSectionFooter={()=><Text style={{ fontSize: 38, backgroundColor: 'lightpink', width: '100%' }}>section footer</Text>}
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
```
<img width="413" alt="螢幕快照 2019-10-21 下午12 23 36" src="https://user-images.githubusercontent.com/1477985/67176763-030df580-f3fe-11e9-938f-38939339bf5c.png">

after this fix, the separators will display in the right place
<img width="414" alt="螢幕快照 2019-10-21 下午12 23 51" src="https://user-images.githubusercontent.com/1477985/67176795-2042c400-f3fe-11e9-96f3-a8ea1cfb28a2.png">

Differential Revision: D18174225

Pulled By: cpojer

fbshipit-source-id: 30901e68f38326c69715514a09a7a5130a2332a0
@stale
Copy link

stale bot commented Oct 31, 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 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 31, 2019
@terrysahaidak
Copy link
Author

I will check the latest pr and write back here :)

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

stale bot commented Jan 30, 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 30, 2020
@stale
Copy link

stale bot commented Feb 6, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Feb 6, 2020
@facebook facebook locked as resolved and limited conversation to collaborators Feb 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: SectionList Priority: Low Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

7 participants