Skip to content

Commit

Permalink
Revert "fix: KeyboardAvoidingView height when "Prefer Cross-Fade Tran…
Browse files Browse the repository at this point in the history
…sitions" is enabled (#34503)"

This reverts commit ec0049b.
  • Loading branch information
kelset committed Oct 3, 2022
1 parent a54ba33 commit 9fd7643
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -72,24 +71,12 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this.viewRef = React.createRef();
}

async _relativeKeyboardHeight(
keyboardFrame: KeyboardEventCoordinates,
): Promise<number> {
_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);

Expand All @@ -103,7 +90,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this._updateBottomIfNecessary();
};

_onLayout = async (event: ViewLayoutEvent) => {
_onLayout = (event: ViewLayoutEvent) => {
const wasFrameNull = this._frame == null;
this._frame = event.nativeEvent.layout;
if (!this._initialFrameHeight) {
Expand All @@ -112,22 +99,22 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}

if (wasFrameNull) {
await this._updateBottomIfNecessary();
this._updateBottomIfNecessary();
}

if (this.props.onLayout) {
this.props.onLayout(event);
}
};

_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;
Expand Down

0 comments on commit 9fd7643

Please sign in to comment.