Shopify / flash-list

A better list for React Native
https://shopify.github.io/flash-list/
MIT License
5.63k stars 283 forks source link

iOS: First Sticky Header component renders on top of ListHeaderComponent on mount, disappears on scroll #727

Open chvanlennep opened 1 year ago

chvanlennep commented 1 year ago

Current behavior

On iOS, when stickyHeaderIndices are used together with ListHeaderComponent, the first sticky header component renders over the ListHeaderComponent, as well as in its expected position on mount. It then disappears on scroll.

https://user-images.githubusercontent.com/64969786/210535528-a85c6085-823b-44d9-a3a5-068efe06bc44.mp4

Expected behavior

Sticky headers should not be duplicated.

To Reproduce

This is a minimal repo which demonstrates the bug (note that is intermittent, you may have to reload a few times):

https://github.com/chvanlennep/flashlistheaders-demo

Platform:

Environment

"dependencies": { "@shopify/flash-list": "^1.4.0", "react": "18.0.0", "react-native": "0.69.5" }

mjvestal commented 1 year ago

I ran into this issue. I am getting around it by adding an item to the list data that represents what I want to render as the ListHeaderComponent and instead rendering the header in renderItem.

So in my case this works:

data=[
  { type: 'header' }, // renderItem renders ListHeaderComponent
  { type: 'thing-that-sticks },
  {
     type: 'data-item',
     ...
   }, // many of these
]
stickyHeaderIndices={[1]}

But what I'd expect to work, doesn't

data=[
  { type: 'thing-that-sticks },
  {
     type: 'data-item',
     ...
   }, // many of these
]
stickyHeaderIndices={[0]}
ListHeaderComponent={ListHeaderComponent}
GregoryNative commented 1 year ago

Hey, any updates on that?

KarlosQ commented 1 year ago

This keeps happening (RN 0.72.6 & 1.6.2)

iway1 commented 11 months ago

if this isn't gonna be fixed soon maybe add a warning that stickyHeaderIndices and ListHeaderComponent are incompatibles people don't ship this bug by mistake

lsarni commented 3 months ago

We are having the same problem on Android on ^1.7.0

MaxTheTurtle0 commented 2 weeks ago

Did anyone find a workaround/fix yet?