diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 7c794ea5e8dcaf..061a21bee21f4b 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -118,7 +118,28 @@ class KeyboardAvoidingView extends React.Component { _onLayout = (event: ViewLayoutEvent) => { this._frame = event.nativeEvent.layout; - if (!this._initialFrameHeight) { + + let isInitial = !this._initialFrameHeight; + + if (this.viewRef.current !== null) { + // Try to measure inside the window, not the view controller + this.viewRef.current.measureInWindow((x, y, width, height) => { + const frame: ViewLayout = { + x: x, + y: y, + width: width, + height: height, + }; + this._frame = frame; + + if (isInitial) { + // save the initial frame height, before the keyboard is visible + this._initialFrameHeight = frame.height; + } + }); + } + + if (isInitial) { // save the initial frame height, before the keyboard is visible this._initialFrameHeight = this._frame.height; }