[iOS] Fix keyboard inset state across ScrollView recycling - #57811
[iOS] Fix keyboard inset state across ScrollView recycling#57811stareezy-1 wants to merge 1 commit into
Conversation
|
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D114719614. |
|
Verified on device against the reproducer from #57755. iPhone 17 Pro, iOS 26.5.2, RN 0.86.2, Release build, React core built from source. Baseline immediately before, same device and toolchain: 10 cycles, 36 corrupt readings, phantom contentInset.bottom of 217.3 on a ScrollView that never set the prop. With this patch: 49 cycles including runs with a stall during teardown, 0 corrupt readings, no inset writes to pooled views, and views that do opt in still receive their insets after being recycled. One note for anyone else verifying on 0.86.2: React core is prebuilt by default, so edits to RCTScrollViewComponentView.mm in node_modules never reach the binary. You need RCT_USE_PREBUILT_RNCORE=0 and a fresh pod install. I did not exercise the true-to-true reuse case that the unconditional assignment protects against; your unit test covers it. |
Summary:
Closes #57755.
RCTScrollViewComponentViewremained subscribed to keyboard notifications while pooled with_automaticallyAdjustKeyboardInsetsstill enabled. A late notification could therefore restore keyboard insets afterprepareForRecyclehad cleared them.Disarm keyboard inset adjustment during recycling, then always synchronize the flag from the incoming props so a recycled view is correctly re-armed when the next ScrollView opts in.
Changelog:
[IOS] [FIXED] - Prevent recycled ScrollViews from retaining automatic keyboard inset behavior.
Test Plan:
RCTScrollViewComponentViewTests.testAutomaticallyAdjustKeyboardInsetsAcrossRecycling, covering enabled behavior, ignored keyboard notifications while recycled, and re-enabling after remount./Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-format --dry-run --Werror packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm packages/react-native/React/Tests/Mounting/RCTScrollViewComponentViewTests.mmgit diff --checkThe full native XCTest suite was not run locally because this sparse checkout does not include a bootstrapped RNTester/CocoaPods workspace.