react-native/packages
Samuel Susla 510d2906b2 maintain correct content offset when scroll view is suspended (#44256)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/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
2024-04-25 09:20:42 -07:00
..
assets Pre-suppress unsafe string key access errors in xplat/js (#44221) 2024-04-23 11:36:14 -07:00
babel-plugin-codegen
community-cli-plugin chore(dev-middleware): add localhost as default host in start command config (#44244) 2024-04-25 03:01:51 -07:00
core-cli-utils core-cli-utils - Added version information 2024-04-11 07:59:01 -07:00
debugger-frontend Update debugger-frontend from b6c974c...24b0c81 (#44181) 2024-04-22 08:12:09 -07:00
dev-middleware Align debugger Chrome launch flags with Meta-internal version (#44180) 2024-04-22 08:37:32 -07:00
eslint-config-react-native
eslint-plugin-react-native
eslint-plugin-specs
helloworld Add an internal HelloWorld template 2024-04-23 15:07:59 -07:00
hermes-inspector-msggen
metro-config
normalize-color
polyfills
react-native maintain correct content offset when scroll view is suspended (#44256) 2024-04-25 09:20:42 -07:00
react-native-babel-preset
react-native-babel-transformer
react-native-bots
react-native-codegen Pre-suppress unsafe string key access errors in xplat/js (#44221) 2024-04-23 11:36:14 -07:00
react-native-codegen-typescript-test
react-native-gradle-plugin Clarify documentation for debuggableVariants (#44040) 2024-04-15 06:54:33 -07:00
react-native-info react-native-info - clean up licenses + docs 2024-04-11 05:16:46 -07:00
react-native-popup-menu-android rename PopupMenuAndroid.onPopupDismiss (#44109) 2024-04-19 08:34:40 -07:00
react-native-test-library Fix @react-native/oss-library-example package.json#exports (#44179) 2024-04-22 05:23:04 -07:00
react-native-test-renderer
rn-tester Handle fontWeight normalization for TextInput component 2024-04-24 16:02:46 -07:00
rn-tester-e2e Deploy 0.235.1 to xplat 2024-04-24 12:27:04 -07:00
typescript-config
virtualized-lists Pre-suppress unsafe string key access errors in xplat/js (#44221) 2024-04-23 11:36:14 -07:00