Skip to content
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

TextInput.onKeyPress: nativeEvent.key is an empty string when a non-ASCII character is entered #45199

Closed
pklatka opened this issue Jun 27, 2024 · 5 comments
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@pklatka
Copy link

pklatka commented Jun 27, 2024

Description

When a non-ASCII character is entered in the TextInput component, onKeyPress does not return proper key value. This issue doesn't exist on old architecture.

Steps to reproduce

  1. Clone the reproducer
  2. Install project dependencies with npm
  3. Run the app with npm run ios
  4. Try entering non-ASCII characters (e.g., characters with accents, Cyrillic, Chinese characters, emoji) in the TextInput
  5. Observe that the onKeyPress does not return the correct values for these characters.

React Native Version

0.74.2

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (11) arm64 Apple M3 Pro
  Memory: 99.61 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

This issue isn't a crash or failure.

Reproducer

https://github.com/pklatka/non-ascii-key-press-repro

Screenshots and Videos

New architecture Old architecture
NEW_ARCH.mp4
OLD_ARCH.mp4
@pklatka pklatka added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jun 27, 2024
@github-actions github-actions bot added the Component: TextInput Related to the TextInput component. label Jun 27, 2024
@pklatka
Copy link
Author

pklatka commented Jun 27, 2024

I guess that this might be caused by how keyPressMetricsPayload is implemented - the key which is passed to the event object is always a one char.

@cortinico cortinico added the Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. label Jun 27, 2024
@arushikesarwani94
Copy link
Contributor

arushikesarwani94 commented Jul 1, 2024

And by

Run the app with npm run ios or npm run android

I assume it's happening both on Android & iOS or just an iOS thing since it might be caused by iostextinput ?

@pklatka
Copy link
Author

pklatka commented Jul 2, 2024

I could only reproduce that on iOS (I forgot to update this repro step 😕)

@arushikesarwani94
Copy link
Contributor

The problem is also entering non ASCII character (é) is being registered as onChange event instead of onKeyPress

@arushikesarwani94
Copy link
Contributor

@pklatka @deepanshushuklad11 Can you try #45274 with Cyrillic, Chinese characters. I have verified it works for accent letters & Emojis on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants