mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix ScrollView automaticallyAdjustKeyboardInsets not resetting when Prefer Cross-Fade Transitions is enabled (#35933)
Summary: Similar to the issue here https://github.com/facebook/react-native/pull/34503 but this is also happening if we just use `ScrollView` and `TextInput` with `automaticallyAdjustKeyboardInsets` enabled. When we enable `Prefer Cross-Fade Transitions` in `iOS` we get a keyboard height of `0` which causes the inset/offset miscalculation and the content jumps up when the keyboard gets hidden. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [IOS] [FIXED] - Fix ScrollView `automaticallyAdjustKeyboardInsets` not resetting when Prefer Cross-Fade Transitions is enabled and keyboard hides For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [FIXED] - Fix ScrollView `automaticallyAdjustKeyboardInsets` not resetting when Prefer Cross-Fade Transitions is enabled and keyboard hides Pull Request resolved: https://github.com/facebook/react-native/pull/35933 Test Plan: Tested with brand new react native project with/without the fix before fix `automaticallyAdjustKeyboardInsets` with enabled/disabled opening/closing keyboard https://user-images.githubusercontent.com/6507800/214039873-33bfb016-f99f-4644-9174-20bf32cf07d6.mov after fix `automaticallyAdjustKeyboardInsets` with enabled/disabled opening/closing keyboard https://user-images.githubusercontent.com/6507800/214039887-4054a749-ab15-4399-b6a9-73dc9283aa6b.mov Reviewed By: christophpurrer Differential Revision: D42686390 Pulled By: jacdebug fbshipit-source-id: 98488e0c9639c19a4acae1a1de1a5fde411e2462
This commit is contained in:
committed by
Facebook GitHub Bot
parent
efe5f62f91
commit
b8f1bb50f7
@@ -331,6 +331,16 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
||||
newContentOffset.y -= contentDiff;
|
||||
}
|
||||
|
||||
if (@available(iOS 14.0, *)) {
|
||||
// On iOS when Prefer Cross-Fade Transitions is enabled, the keyboard position
|
||||
// & height is reported differently (0 instead of Y position value matching height of frame)
|
||||
// Fixes similar issue we saw with https://github.com/facebook/react-native/pull/34503
|
||||
if (UIAccessibilityPrefersCrossFadeTransitions() && endFrame.size.height == 0) {
|
||||
newContentOffset.y = 0;
|
||||
newEdgeInsets.bottom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[UIView animateWithDuration:duration
|
||||
delay:0.0
|
||||
options:animationOptionsWithCurve(curve)
|
||||
|
||||
Reference in New Issue
Block a user