fix: bug with KeyboardChatScrollView + inverted + maintainVisibleScrollPosition + FlashList#1437
Merged
kirillzyusko merged 5 commits intomainfrom Apr 20, 2026
Conversation
Contributor
📊 Package size report
|
KeyboardChatScrollView + inverted + maintainVisibleScrollPosition + FlashListKeyboardChatScrollView + inverted + maintainVisibleScrollPosition + FlashList
…nVisibleScrollPosition` + `FlashList`
301786c to
451d730
Compare
Contributor
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixed a problem with non-working
maintainVisibleScrollPositionwhen usinginvertedprop ofKeyboardChatScrollView.💡 Motivation and Context
The issue stems from the fact that we use additional
ViewinKeyboardChatScrollView:It totally breaks
maintainVisibleScrollPositionbehavior. The algorithm is similar on both iOS/Android, but we'll use Android code snippets for demonstration. First of all it iterates over direct children ofcontentView:So when we draw additional
View- the algorithm becomes completely broken. Further the code does something like this:But this code will never work properly, because on first step we will not be able to compute proper
prevFirstVisibleFrame(since we have only singleViewand thisViewis always visible).First idea that I had in my mind was adding
TransientViewthat would substitutechildCount/getChildAtand forward them down to inner children. However it significantly increases the complexity of the app. And I decided to dig deeper into "why exactly I added this code?".The reason was very simple. My virtualized list example was flickering during keyboard animation (pay attention to "So far it looks cool!" message in the bottom of the screen):
telegram-cloud-document-2-5409326574178701854.mp4
If we check debugger we can see that this item has been recycled:
Important
This issue seems to be reproducible only with
FlashList(notFlatList). If I remember correctlyFlatListtries to mount all items if we don't provide a function for layout prediction (just do it in batch updates).FlashListactually recycles items (and because of that it has better memory footprint). So the issue is reproducible only inFlashListsince it recycles items.Warning
I also managed to reproduce it on new arch only. Old arch works well even without
drawDistancespecification 🤷♂️I think this problem is caused by the fact that we change
translateYof the content and perform scroll. In this case visible items are not the same thatFlashListthinks are visible (becauseFlashListdoesn't know anything abouttranslateYthat was modified natively).So the fix is to remove additional view and simply increase
windowSizein example app (I also mentioned this side effect in documentation).Additionally I think that this fake
Viewmay completely break recycling ofFlashListbecause we render a single bigViewwhich technically is always visible 🤷♂️So in general: rendering additional
Viewmay break many things (maintainVisibleScrollPosition, recycling) so it's not a correct solution. Current solution - remove that fake view AND increase rendering buffer for virtualized lists.Closes #1423
📢 Changelog
Docs
invertedprop may require enhanceddrawDistance;JS
Viewwhen renderinginvertedlist;Android
contentViewdirectly (no first child ofcontentViewanymore) for modifyingtranslateYposiiton;🤔 How Has This Been Tested?
Tested manually on Pixel 7 Pro (API 36).
📸 Screenshots (if appropriate):
Flickering
telegram-cloud-document-2-5409326574178701854.mp4
telegram-cloud-document-2-5409326574178701877.mp4
Auto-scrolling
telegram-cloud-document-2-5409326574178701952.mp4
telegram-cloud-document-2-5409326574178701946.mp4
📝 Checklist