[iOS] Fix ScrollView stale keyboard inset after dismiss#56189
[iOS] Fix ScrollView stale keyboard inset after dismiss#56189Miyou wants to merge 2 commits intofacebook:mainfrom
Conversation
|
Hi @Miyou! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
This fixes an iOS
ScrollViewbug where usingautomaticallyAdjustKeyboardInsetstogether withcontentInsetAdjustmentBehavior="automatic"can leave a stale bottom gap after the keyboard is dismissed. The extra space is not cleared until the user scrolls again.The underlying issue is that the keyboard dismissal path can call
scrollToOffsetwith an offset that needs to be clamped against the new inset-adjusted bounds, but the current code checks for an unchangedcontentOffsetbefore that clamping happens. WhenadjustedContentInsetshrinks after the keyboard closes, the numeric offset can compare equal while still being outside the valid range, sosetContentOffsetis skipped and the stale gap remains visible.This change:
adjustedContentInsetwhen available) when computing the valid scroll rangeautomaticallyAdjustKeyboardInsets+contentInsetAdjustmentBehavior="automatic"combinationChangelog:
[IOS] [FIXED] Fix
ScrollViewleaving stale bottom inset after keyboard dismissal when usingautomaticallyAdjustKeyboardInsetswith automatic content inset adjustmentTest Plan:
automaticallyAdjustKeyboardInsetscontentInsetAdjustmentBehavior="automatic"TextInputnear the bottom of the scroll viewScrollViewKeyboardInsetsIOSExample.jsthat reproduces this exact prop combination for upstream verification.Build/validation details:
npx expo prebuild --platform ios --no-installnpx pod-install iosxcodebuild -workspace ios/scrollviewautomaticallyadjustkeyboardinsetsbug.xcworkspace -scheme scrollviewautomaticallyadjustkeyboardinsetsbug -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 16 Pro' build