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

Inverted FlashLists do not interact correctly with Sticky Item Headers #611

Open
gjbadros opened this issue Sep 22, 2022 · 12 comments
Open
Labels
bug Something isn't working P1 Important but not urgent

Comments

@gjbadros
Copy link

Current behavior

Sticky item headers, when using FlashList.inverted=true prop, show up on the bottom upside down. See the blue rectangle in the bottom right of image

Expected behavior

Ideally, there'd be a prop about headersAt='top'|'bottom' and we could specify that and you'd apply the scaleTransform -1 a second time on the headers and get them in the right place.

You can see how the app behaves more generally by looking at the currently-in-production FlatList-based version (see https://gluroo.com )

To Reproduce

Just use inverted prob with sticky headers.

Platform:

  • [ X ] iOS
  • [ X ] Android

Environment

1.2.2

@gjbadros gjbadros added the bug Something isn't working label Sep 22, 2022
@gjbadros
Copy link
Author

BTW, I also suspect that resizing an element when Inverted=true will result in the opposite "gravity" of what is desired -- that the element's top will move up on the physical screen instead of staying in place, and ideally the gravity would be inverted, too, so an element being clicked to get bigger keeps the top of its bounding box in place instead of the bottom of its bounding box in place.

@naqvitalha
Copy link
Collaborator

@gjbadros We don't support sticky headers in the inverted mode right now. It's not being removed due to a bug but ideally, it shouldn't even show up.

@gjbadros
Copy link
Author

That should either be mentioned here: https://shopify.github.io/flash-list/docs/known-issues or https://shopify.github.io/flash-list/docs/usage#inverted

Consider updating your docs, at least, to make this shortcoming clear.

@naqvitalha
Copy link
Collaborator

The idea was to throw a warning. I'm going to look into adding it soon. Thanks for the suggestion!

@gjbadros
Copy link
Author

I don't think it's so hard to fix, FWIW, but I already had a workaround for FlatList and it adapted easily for FlashList because scrollToOffset() is already exposed, so it's not worth implementing in FlashList in the short term for me.

Regardless, the warning would certainly be nice, but documenting it, too, is at least as important for folks considering switching and hoping for inverted to work better than FlatList's partial implementation.

@naqvitalha
Copy link
Collaborator

Can you post your solution here? It might help others as well

@gjbadros
Copy link
Author

My solution just uses onViewableItemsChanged to track what's on screen and set a specific header element at the top to the element with a stickyIndex after (i.e., above) the last element that's on screen. Then any time an element changes size I manually compute the difference in height and do the compensating scrollToOffset(). Right now I use an onScroll prop to updateContentOffset notion (but that shouldn't be necessary if there's a lookup to the current contentOffset -- FlatList didn't seem to have one.

But I don't want to make it too easy to do my hack, since without it, the easier fix is just to fix FlashList, which is better for everyone :-)

@naqvitalha naqvitalha reopened this Sep 26, 2022
@naqvitalha naqvitalha added the P1 Important but not urgent label Sep 26, 2022
@ramssutharr
Copy link

any update on this ? I'm using flash list for chat and badly need this without a custom solution.

@thanhloc-17
Copy link

up

@pavelustenko
Copy link

All chat developers would be happy if this could be implemented.

@gunnartorfis
Copy link

Figured I'd bump since it's been a while, for my fellow chat developers.

@kamelmojawaz1
Copy link

Pump it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 Important but not urgent
Projects
None yet
Development

No branches or pull requests

7 participants