Fix ScrollView recycled content inset#57494
Open
adamivancza wants to merge 1 commit into
Open
Conversation
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D111262993. |
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.
Summary:
Fixes #57314.
When a Fabric
ScrollViewis recycled on iOS,prepareForRecycleresets native scroll state before the view is reused.contentInsetwas being reset toUIEdgeInsetsZero, which prevents stale native insets from leaking between recycled views, but also drops a valid non-zerocontentInsetfrom the current props.If the recycled view is mounted again with the same
contentInsetprop value,updatePropsmay not reapply it because the props did not change. This can leave the nativeUIScrollViewwithcontentInset = 0even though React props still specify a non-zero inset.This change keeps the stale-state protection, but resets
contentInsetback to the value from the current props instead of always zeroing it.Changelog:
[IOS] [FIXED] - Preserve Fabric ScrollView contentInset when recycling iOS native views
Test Plan:
Verified with the repro from #57314:
gimi-anders/rn-contentinset-recycle-repronative contentInset.top = 200native contentInset.top = 0native contentInset.top = 200Also verified that the previous stale-inset protection is preserved:
prepareForRecyclestill overwrites the recycled nativeUIScrollView.contentInset; it now overwrites it with the current props value instead of always usingUIEdgeInsetsZero.