-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
maintain correct content offset when scroll view is suspended #44256
Closed
Conversation
This file contains 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
facebook-github-bot
added
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
p: Facebook
Partner: Facebook
Partner
labels
Apr 25, 2024
sammy-SC
force-pushed
the
export-D56573370
branch
from
April 25, 2024 15:16
c4637be
to
0fd41a8
Compare
…ok#44256) Summary: Pull Request resolved: facebook#44256 ## Changelog: [iOS] [Fixed] - Preserve content offset in ScrollView when the component is suspended # The problem On iOS, components are recycled. For ScrollView, its content offset has to be reset back to original position. When we call `[UIScrollView setContentOffset:]`, it triggers all of its delegate methods and triggers `scrollViewDidScroll` where we set native state. So when user scrolls to position 100 and scroll view suspends. it is removed from view hierarchy and recycled. Once the suspense boundary is resolved, scroll view will be inserted back into view hierarchy. But when it was recycled, we set back its original content offset (the default is 0, 0) but this was accidentally propagated through to shadow tree. # Solution To avoid this, we simply need to invalidate `_state` before calling `[UIScrollView setContentOffset:]`. Reviewed By: cipolleschi Differential Revision: D56573370
sammy-SC
force-pushed
the
export-D56573370
branch
from
April 25, 2024 15:24
0fd41a8
to
cce6730
Compare
This pull request has been merged in 510d290. |
This pull request was successfully merged by @sammy-SC in 510d290. When will my fix make it into a release? | How to file a pick request? |
cipolleschi
pushed a commit
that referenced
this pull request
May 1, 2024
Summary: Pull Request resolved: #44256 [iOS] [Fixed] - Preserve content offset in ScrollView when the component is suspended On iOS, components are recycled. For ScrollView, its content offset has to be reset back to original position. When we call `[UIScrollView setContentOffset:]`, it triggers all of its delegate methods and triggers `scrollViewDidScroll` where we set native state. So when user scrolls to position 100 and scroll view suspends. it is removed from view hierarchy and recycled. Once the suspense boundary is resolved, scroll view will be inserted back into view hierarchy. But when it was recycled, we set back its original content offset (the default is 0, 0) but this was accidentally propagated through to shadow tree. To avoid this, we simply need to invalidate `_state` before calling `[UIScrollView setContentOffset:]`. Reviewed By: cipolleschi Differential Revision: D56573370 fbshipit-source-id: c03d7d2d403af2e1649b4cf189072baeb4c286c8
kosmydel
pushed a commit
to kosmydel/react-native
that referenced
this pull request
May 6, 2024
…ok#44256) Summary: Pull Request resolved: facebook#44256 ## Changelog: [iOS] [Fixed] - Preserve content offset in ScrollView when the component is suspended # The problem On iOS, components are recycled. For ScrollView, its content offset has to be reset back to original position. When we call `[UIScrollView setContentOffset:]`, it triggers all of its delegate methods and triggers `scrollViewDidScroll` where we set native state. So when user scrolls to position 100 and scroll view suspends. it is removed from view hierarchy and recycled. Once the suspense boundary is resolved, scroll view will be inserted back into view hierarchy. But when it was recycled, we set back its original content offset (the default is 0, 0) but this was accidentally propagated through to shadow tree. # Solution To avoid this, we simply need to invalidate `_state` before calling `[UIScrollView setContentOffset:]`. Reviewed By: cipolleschi Differential Revision: D56573370 fbshipit-source-id: c03d7d2d403af2e1649b4cf189072baeb4c286c8
kosmydel
pushed a commit
to kosmydel/react-native
that referenced
this pull request
Jun 11, 2024
…ok#44256) Summary: Pull Request resolved: facebook#44256 ## Changelog: [iOS] [Fixed] - Preserve content offset in ScrollView when the component is suspended # The problem On iOS, components are recycled. For ScrollView, its content offset has to be reset back to original position. When we call `[UIScrollView setContentOffset:]`, it triggers all of its delegate methods and triggers `scrollViewDidScroll` where we set native state. So when user scrolls to position 100 and scroll view suspends. it is removed from view hierarchy and recycled. Once the suspense boundary is resolved, scroll view will be inserted back into view hierarchy. But when it was recycled, we set back its original content offset (the default is 0, 0) but this was accidentally propagated through to shadow tree. # Solution To avoid this, we simply need to invalidate `_state` before calling `[UIScrollView setContentOffset:]`. Reviewed By: cipolleschi Differential Revision: D56573370 fbshipit-source-id: c03d7d2d403af2e1649b4cf189072baeb4c286c8
This was referenced Jun 28, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
p: Facebook
Partner: Facebook
Partner
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:
Changelog:
[iOS] [Fixed] - Preserve content offset in ScrollView when the component is suspended
The problem
On iOS, components are recycled. For ScrollView, its content offset has to be reset back to original position. When we call
[UIScrollView setContentOffset:]
, it triggers all of its delegate methods and triggersscrollViewDidScroll
where we set native state.So when user scrolls to position 100 and scroll view suspends. it is removed from view hierarchy and recycled. Once the suspense boundary is resolved, scroll view will be inserted back into view hierarchy. But when it was recycled, we set back its original content offset (the default is 0, 0) but this was accidentally propagated through to shadow tree.
Solution
To avoid this, we simply need to invalidate
_state
before calling[UIScrollView setContentOffset:]
.Differential Revision: D56573370