From 9fd764388a0963cddbeafdcea2d830937ad716b2 Mon Sep 17 00:00:00 2001 From: Lorenzo Sciandra Date: Mon, 3 Oct 2022 13:07:13 +0100 Subject: [PATCH] Revert "fix: KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled (#34503)" This reverts commit ec0049b0083b931e6fb4c6da4c51e2a091e05da1. --- .../Keyboard/KeyboardAvoidingView.js | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index f7914cb6df0737..4536402c5104f6 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -23,7 +23,6 @@ import type { ViewLayoutEvent, } from '../View/ViewPropTypes'; import type {KeyboardEvent, KeyboardEventCoordinates} from './Keyboard'; -import AccessibilityInfo from '../AccessibilityInfo/AccessibilityInfo'; type Props = $ReadOnly<{| ...ViewProps, @@ -72,24 +71,12 @@ class KeyboardAvoidingView extends React.Component { this.viewRef = React.createRef(); } - async _relativeKeyboardHeight( - keyboardFrame: KeyboardEventCoordinates, - ): Promise { + _relativeKeyboardHeight(keyboardFrame: KeyboardEventCoordinates): number { const frame = this._frame; if (!frame || !keyboardFrame) { return 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) - if ( - Platform.OS === 'ios' && - keyboardFrame.screenY === 0 && - (await AccessibilityInfo.prefersCrossFadeTransitions()) - ) { - return 0; - } - const keyboardY = keyboardFrame.screenY - (this.props.keyboardVerticalOffset ?? 0); @@ -103,7 +90,7 @@ class KeyboardAvoidingView extends React.Component { this._updateBottomIfNecessary(); }; - _onLayout = async (event: ViewLayoutEvent) => { + _onLayout = (event: ViewLayoutEvent) => { const wasFrameNull = this._frame == null; this._frame = event.nativeEvent.layout; if (!this._initialFrameHeight) { @@ -112,7 +99,7 @@ class KeyboardAvoidingView extends React.Component { } if (wasFrameNull) { - await this._updateBottomIfNecessary(); + this._updateBottomIfNecessary(); } if (this.props.onLayout) { @@ -120,14 +107,14 @@ class KeyboardAvoidingView extends React.Component { } }; - _updateBottomIfNecessary = async () => { + _updateBottomIfNecessary = () => { if (this._keyboardEvent == null) { this.setState({bottom: 0}); return; } const {duration, easing, endCoordinates} = this._keyboardEvent; - const height = await this._relativeKeyboardHeight(endCoordinates); + const height = this._relativeKeyboardHeight(endCoordinates); if (this.state.bottom === height) { return;