Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: incorrect ScrollView offset on update (#30647)
Summary: This pull request is to fix #30258. After an investigation, I found out the scroll offset of the list seems to be calculated incorrectly due to a workaround in the source code. Instead of fixing the `calculateOffsetForContentSize`, I chose to remove it, the reason why I do so is because this workaround is for fixing the offset when `contentSize` is set manually, but according to the source code, there is no interface for a react-native user to set the `contentSize` of ScrollView, it is just set to `GCSizeZero` and will never be changed ([ref](https://github.com/facebook/react-native/pull/30647/files#diff-cf6f991f585ebf4cfdd555fe474e1f9ce40c2e4f823fc3f42b549414639c8c30L304)). Also I changed the function name from `updateContentOffsetIfNeeded` to `updateContentSizeIfNeeded` according what the function is actually doing. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - Incorrect ScrollView offset on update Pull Request resolved: #30647 Test Plan: 1. Create a fresh new project named `testapp` using npx create-react-native-app 2. Apply example code to `testapp` from https://snack.expo.io/lokomass/flatlist 3. Run `testapp` on iOS emulator and reproduce the bug 4. Make changes to files in `testapp/node_modules/react-native/` 5. Rebuild `testapp` and run on iOS emulator again, the bug is no more exist 6. Apply changes from step 4 to react-native, make a pull request. #### Screenshots Before: The scroll offset is incorrect after children of FlatList has changed https://user-images.githubusercontent.com/48589760/103155130-b54a0580-47d7-11eb-97af-bdfd3e728714.mov After: No more incorrect scroll offset if children of FlatList has changed https://user-images.githubusercontent.com/48589760/103155091-6ef4a680-47d7-11eb-89fa-6f708bfef1c9.mov Reviewed By: sammy-SC Differential Revision: D25732958 Pulled By: shergin fbshipit-source-id: dac6eff15ac3bbfec502452ac14b3d49fee76c29
- Loading branch information