Closed
Description
Is this a bug report?
Yes.
Have you read the Contributing Guidelines?
Yes.
Environment
Environment:
- OS: macOS Sierra 10.12.6
- Node: 6.5.0
- Yarn: 0.22.0
- npm: 4.1.1
- Watchman: 4.7.0
- Xcode: Xcode 9.0 Build version 9A235
- Android Studio: 2.2 AI-145.3537739
Packages: (wanted => installed)
- react: 16.0.0-alpha.12 => 16.0.0-alpha.12
- react-native: ^0.48.4 => 0.48.4
Target Platform: Android (API >= 25)
Steps to Reproduce
- Setup a keyboard event listener for
keyboardDidShow
andkeyboardDidHide
:
import { Keyboard } from 'react-native';
Keyboard.addListener('keyboardDidShow', () => {
console.log('keyboardDidShow');
});
Keyboard.addListener('keyboardDidHide', () => {
console.log('keyboardDidHide');
});
- On an Android tablet (API 25+), enter split-screen mode (long press the square in the bottom thing), and drag to resize the react-native view smaller. Everytime the view goes from taller to shorter, both keyboard events fire.
Expected Behavior
- Since there's no keyboard on the screen, and no input that could potentially trigger one, I wouldn't expect any keyboard events to be published.
Actual Behavior
- Keyboard events are fired when no keyboard is in sight.
Note the console logs for keyboard events in the debugger.
I suspect it's due to ReactRootView checking to see if the screen size shrunk by at least the height of a keyboard (which in this case it did), and it thinks that the viewport change was caused by a keyboard poping up.
ReactRootView.java#checkForKeyboardEvents
Reproducible Demo
https://snack.expo.io/rkKcJ1W0W
-- or --
https://gist.github.com/adierkens/f7ea7c7dbd6b9da18b9fc6f2b2e0a664
Note: split screen mode is only API 25+, since the snack preview only supports 21 and 22, the preview doesn't exhibit the bug behavior.