From 8a1f6c858a6b19cad904bbac1ba28847b634e3fd Mon Sep 17 00:00:00 2001 From: Brandon Yuen Date: Wed, 27 Jul 2022 15:40:15 +0200 Subject: [PATCH] fix: reduce motion on iOS 14 breaks KeyboardAvoidingView With iOS 14 & Reduce Motion > Prefer Cross-Fade Transitions enabled, the keyboard position & height is reported differently (0 instead of Y position value matching height of frame). See: facebook#29974 (comment) This commit implements the fix mentioned in the link above. --- Libraries/Components/Keyboard/KeyboardAvoidingView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 4536402c5104f6..a630545ee227fa 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -73,7 +73,9 @@ class KeyboardAvoidingView extends React.Component { _relativeKeyboardHeight(keyboardFrame: KeyboardEventCoordinates): number { const frame = this._frame; - if (!frame || !keyboardFrame) { + // with iOS 14 & Reduce Motion > Prefer Cross-Fade Transitions enabled, the keyboard position + // & height is reported differently (0 instead of Y position value matching height of frame) + if (!frame || !keyboardFrame || keyboardFrame.screenY === 0) { return 0; }