From 45954ac5dccdfe05de7553a0f08c4f0e66e3d62e Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Wed, 15 Jul 2020 13:12:55 -0700 Subject: [PATCH] keyboardDidHide wrong screenY coordinates with windowTranslucentStatus=true (#29292) Summary: This issue fixes https://github.com/facebook/react-native/issues/27526, related issue https://github.com/facebook/react-native/issues/27089 Avoid returning the wrong screenY coordinates on event keyboardDidHide. getWindowVisibleDisplayFrame retrieves the overall visible display size in which the window this view is attached to has been positioned in. This takes into account screen decorations above the window, for both cases where the window itself is being position inside of them or the window is being placed under then and covered insets are used for the window to position its content inside. In effect, this tells you the available area where content can be placed and remain visible to users, since anything below the StatusBar is not visible to the user, the method does not work with translucent StatusBar (android:windowTranslucentStatus). This commit fixes this issues removing the white bar at the bottom of the view when using windowTranslucentStatus. ## Changelog [Android] [Fixed] - keyboardDidHide wrong screenY coordinates with windowTranslucentStatus=true Pull Request resolved: https://github.com/facebook/react-native/pull/29292 Test Plan: Works in all scenarios, but **I did not change RNTester `windowTranslucentStatus`**. I would like to discuss the potential breaking changes connected to not using [getWindowVisibleDisplayFrame](https://developer.android.com/reference/android/view/View#getWindowVisibleDisplayFrame(android.graphics.Rect)) with `keyboardDidHide`. I would be happy to build an alternative functionality to calculate the WindowVisibleDisplayFrameHeight under request from the Facebook Team. **WITHOUT** `android:windowTranslucentStatus` | **BEFORE** | |:-------------------------:| | | | **AFTER** | |:-------------------------:| | | **WITH** `android:windowTranslucentStatus` | **BEFORE** | |:-------------------------:| | | | **BEFORE (log)** | |:-------------------------:| | | | **AFTER** | |:-------------------------:| | | | **AFTER (log)** | |:-------------------------:| | | RNTester **WITHOUT** `android:windowTranslucentStatus` | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | I remain available to do improvements. Thanks a lot. Fabrizio. Reviewed By: JoshuaGross Differential Revision: D22521125 Pulled By: mdvacca fbshipit-source-id: e2cb90163abb1baa00b1916e431971b011522565 --- .../src/main/java/com/facebook/react/ReactRootView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 43d91482f1af7e..45049cb5a65366 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -684,7 +684,7 @@ private void checkForKeyboardEvents() { sendEvent( "keyboardDidHide", createKeyboardEventPayload( - PixelUtil.toDIPFromPixel(mVisibleViewArea.height()), + PixelUtil.toDIPFromPixel(mLastHeight), 0, PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), 0));