-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard height wrong with notches #26296
Comments
I think this is related to this line, where |
Is there a workaround for this? |
As the |
Thanks - this worked. Other thing to notice about Dimensions.get('window') is that when using gesture action bar on s10+ it returns wrong height value so instead of depending on this you're better of with container onLayout values. |
@MichalKrakow could you please help me understand how you fixed it? I can't figure this out. |
@vandrieu |
@MichalKrakow Got it working! Before:My App:
My component with keyboard:
After:My App:
My component with keyboard:
Thanks! |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
This is still a bug in react-native AFAIK. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Summary: fixes #27089 fixes #30191 fixes #26296 fixes #24353 Related #30052 #28004 #26536 The keyboard height of event keyboardDidShow is computed as the difference of two variables: - The screen height excluding the Android Notch DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels returns the screen height excluding the Android Notch - The Visible Area excluding the Keyboard, but including the Android Notch getWindowVisibleDisplayFrame() which returns the visible area including the Android Notch The computation of the keyboard height is wrong when the device has an Android Notch. This pr adds the Android Notch computation for API levels 28+ More info at #27089 (comment) ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - Compute Android Notch in keyboardDidShow height calculation API 28+ Pull Request resolved: #30919 Test Plan: adding a ReactRootViewTest for keyboardDidShow verifying correct functionality on API < 28 **<details><summary>TEST CASE - BEFORE FIX</summary>** <p> **WITHOUT NOTCH** - The black view on the bottom is visible - The keyboard height is 282 | **Full Screen** | **Keyboard Did Show** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/107212700-a1fd9d00-6a07-11eb-9248-26f9c4d92ae3.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107212590-7975a300-6a07-11eb-89f4-891a37a7c406.png" width="300" height="" /> | **WITH NOTCH** - The black view on the bottom is **not** visible. The black view is not visible because keyboardDidHide is sending the wrong keyboard height value. - The keyboard height changes to 234. The keyboard height is the same from the previous test, but the value sent from keyboardDidHide changed for the Notch. | **Full Screen** | **Keyboard Did Show** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/107212619-81cdde00-6a07-11eb-9630-7e7c8c34d798.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107212707-a4f88d80-6a07-11eb-9134-f077059c83a6.png" width="300" height="" /> | </p> </details> **<details><summary>TEST CASE - AFTER FIX</summary>** <p> **WITH NOTCH** - The black view on the bottom is visible - The keyboard height is 282 | **Full Screen** | **Keyboard Did Show** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/107212619-81cdde00-6a07-11eb-9630-7e7c8c34d798.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107349053-0d0ea880-6ac8-11eb-9695-33128080b6b8.png" width="300" height="" /> | </p> </details> Reviewed By: ShikaSD Differential Revision: D31207989 Pulled By: cortinico fbshipit-source-id: 0955a3884201122166c5c0ae2aca988a0ed4af53
The height of the keyboard as reported by the
keyboardDidShow
event is wrong when a notch is present.React Native version: 0.59.8 (Expo 34.0.0)
Tested on Android
Steps To Reproduce
keyboardDidShow
eventsheight
andscreenY
properties in particular)Dimensions.get('screen')
andDimensions.get('window')
Expected behaviour
The
height
property of thekeyboardDidShow
event reflects the correct height of the keyboardActual behaviour
The height that is returned is slightly smaller than the expected value: the difference seems to be the height of the notch. I assume that the
screenY
property (correctly) reflects the offset from the top of thescreen
(upper side of the notch), but theheight
is calculated using thewindow
dimensions (everything under the notch). For phones that don't have a notch, the top of thescreen
andwindow
are the same, so theheight
is correct. However, on phones with a notch, the top of thewindow
is the bottom of the notch and as a result, the height is too small.Example with actual numbers
Pixel 3 (no notch):
Pixel 3 XL (with notch):
As you can see,
screenY + keyboardHeight = windowHeight
in both cases. AsscreenY
is ascreen
coordinate, notwindow
, this should be equal toscreenHeight
instead.Snack: https://snack.expo.io/Sk_yXw9Sr
The text was updated successfully, but these errors were encountered: