Skip to content

[iOS] Fix keyboard inset state across ScrollView recycling - #57811

Open
stareezy-1 wants to merge 1 commit into
react:mainfrom
stareezy-1:fix/ios-scrollview-keyboard-insets-recycle
Open

[iOS] Fix keyboard inset state across ScrollView recycling#57811
stareezy-1 wants to merge 1 commit into
react:mainfrom
stareezy-1:fix/ios-scrollview-keyboard-insets-recycle

Conversation

@stareezy-1

Copy link
Copy Markdown

Summary:

Closes #57755.

RCTScrollViewComponentView remained subscribed to keyboard notifications while pooled with _automaticallyAdjustKeyboardInsets still enabled. A late notification could therefore restore keyboard insets after prepareForRecycle had 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:

  • Added 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.mm
  • git diff --check

The full native XCTest suite was not run locally because this sparse checkout does not include a bootstrapped RNTester/CocoaPods workspace.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 4, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 4, 2026
@meta-codesync

meta-codesync Bot commented Aug 4, 2026

Copy link
Copy Markdown

@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D114719614.

@PragathiJ

Copy link
Copy Markdown

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.

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS][Fabric] automaticallyAdjustKeyboardInsets state survives ScrollView recycling; recycled views apply keyboard insets they never opted into

2 participants