react-native
react-native copied to clipboard
TextInput's onKeyPress is not working on Android 13
Description
With Android 13, TextInput's onKeyPress does not respond except for the backspace key.
The "Steps to reproduce" shown below did not work correctly onKeyPress on Android 13, but onKeyPress worked fine on Android 11 (A002SO).
Version
0.69.4
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.1
CPU: (10) arm64 Apple M1 Pro
Memory: 218.36 MB / 32.00 GB
Shell: 3.3.1 - /opt/homebrew/bin/fish
Binaries:
Node: 16.13.2 - ~/.nodenv/versions/16.13.2/bin/node
Yarn: Not Found
npm: 8.5.5 - ~/.nodenv/versions/16.13.2/bin/npm
Watchman: 2022.01.31.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 21, 22, 28, 30, 31, 32, 33
Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0
System Images: android-21 | Intel x86 Atom_64, android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom, android-22 | ARM EABI v7a, android-30 | Google APIs ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a, android-33 | Google Play Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 15.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.0.0 => 18.0.0
react-native: 0.69.4 => 0.69.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
-
npm i -g @react-native-community/cli -
npx react-native init MyProject --template "[email protected]" -
cd MyProject -
npm i - Rewrite App.tsx as follows
import React from 'react';
import {SafeAreaView, TextInput} from 'react-native';
const App = () => {
return (
<SafeAreaView>
<TextInput
onKeyPress={e => {
console.log(e.nativeEvent);
}}
style={{width: '100%', height: 100, borderColor: 'red', borderWidth: 1}} />
</SafeAreaView>
);
};
export default App;
- start Metro server with
npm run start - connect macOS and Pixel6(Android13)
- run
npm run androidin another terminal - if the build is successful, the app will start automatically, enter any characters other than backspace in the
TextInputfield - the Metro server should display the text you input here, but nothing is output.
Also, when I changed buildToolsVersion etc in android/build.gradle to 33, onKeyPress did not work correctly and did not show any logs.
buildscript {
ext {
buildToolsVersion = "33"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
Snack, code example, screenshot, or link to a repository
I have filled in the "Steps to reproduce" with the environment and code samples.