Skip to content

Keyboard height is wrong on some Android devices #24353

Closed
@psegalen

Description

@psegalen

🐛 Bug Report

On some Android devices (like on Huawei phones), the event passed as a parameter to the keyboardDidShow listener has a wrong endCoordinates.height property.
I guess it has something to do with the way Android soft navigation bar is handled since Dimensions.get("window") also doesn't behave the same on those devices.

To Reproduce

Clone https://github.com/psegalen/rn-android-keyboard-height-bug
Run the app and give focus to the input.
If you are on a device that has the bug, the keyboard will cover some pixels of the input, if not, the input will have the same position relative to the bottom of the window wether the keyboard is opened or not.
I have reports of the bug by 3 other Huawei phones users so it seems the behaviour only occurs on Huawei phones. Maybe it has something to do with EMUI, Huawei's Android version?

Here are screenshots demonstrating the issue:
Keyboard closed
Keyboard opened

Expected Behavior

The keyboard height should always give the correct value.

Code Example

https://github.com/psegalen/rn-android-keyboard-height-bug

Environment

React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 2.43 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v11.3.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 21, 23, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.1, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.3 => 0.59.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions