flash-list: maintainVisibleContentPosition Not Working

Current behavior

When a maintainVisibleContentPosition prop is given to a FlashList and items are prepended to the data array, the user sees the list content move. This can be observed in the video below. On the left tab, we have React Native’s FlatList, which does not scroll as content is prepended to its data array. On the right tab, we have FlashList, which does scroll as content is prepended, even when providing a valid keyExtractor and a maintainVisibleContentPosition of { minIndexForVisible: 0 }.

https://user-images.githubusercontent.com/229477/182754997-24c6ceaf-bb7f-481e-873d-5d65e2202862.mov

See https://github.com/nickcherry/flashlist-maintain-visible-content-position for reproducible demo.

Expected behavior

I would expect FlashList to behave like FlatList and not scroll when content is prepended to its data and maintainVisibleContentPosition is not undefined.

To Reproduce

https://github.com/nickcherry/flashlist-maintain-visible-content-position

Platform:

  • iOS
  • Android

Environment

1.2.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 17
  • Comments: 24 (2 by maintainers)

Commits related to this issue

Most upvoted comments

The last missing piece for a almost perfect library 😃

maintainVisibleContent position is unsupported right now. We will update here once we get to it.

+1 we really need maintainVisibleContentPosition, please

Would be amazing to get this 🥲

Hey, I’d like to know the advancement on this feature ? Any news ?

Any update?

Any news on this ?

If what you’re referring to is this branch, the commits appear to be just a squash of this PR, which for the reasons I explain in the link from my above comment, cannot fully solve the issue (with problems like not working well during scrolling and not working if the indexes shift too much).

See if my linked fork/patch works well for you, and if it does, it would be great if you added support for my PR to get thoughts and attention of the maintainers.

P.S. With respect to the two flaws I specifically linked to, my fork/patch addresses it respectively in:

  • Mechanism -> Details -> 'Refixing' -> Timing section (_queueLayoutRefix in the recyclerlistview code)
  • Mechanism -> Details -> List changes section (handleDatasetChange in the recyclerlistview code)

Besides these two flaws, my patch addresses a good deal of other edge cases; in the latter part of my explainer, essentially each section corresponds to the presence of an edge case, and how we have dealt with/can deal with it properly.