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 fires after the onChange #48636

Open
ncpa0cpl opened this issue Jan 13, 2025 · 6 comments
Open

TextInput onKeyPress fires after the onChange #48636

ncpa0cpl opened this issue Jan 13, 2025 · 6 comments
Labels
Component: TextInput Related to the TextInput component. Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available

Comments

@ncpa0cpl
Copy link

Description

According to the docs the keyPress event should fire before the change event. That does not seem to be the case though, I've run into this on a physical device in a project (doesn't use expo) I can't share and also reproduced this on a online playground for react native with expo.

In the video you can see that the console.log in the onChange callback happens before the cosnole.log in the onKeyPress callback:

Screencast.From.2025-01-13.14-04-04.mp4

Steps to reproduce

  1. Add the onKeyPress and onChange callbacks to a TextInput
  2. Trigger both events by pressing any key on a keyboard
  3. see that onChange triggers first

React Native Version

tested on 0.74.5 and 0.76.6

Affected Platforms

Runtime - Android

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: Linux 5.10 Manjaro Linux
  CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
  Memory: 18.82 GB / 30.99 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/local/bin/yarn
  npm:
    version: 9.8.1
    path: /usr/local/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: AI-241.18034.62.2411.12169540
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.8
    path: /home/owner/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Stacktrace or Logs

no logs to show

Reproducer

https://snack.expo.dev/@ncpa/rn-bug

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.74.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot react-native-bot added the Component: TextInput Related to the TextInput component. label Jan 13, 2025
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 labels Jan 13, 2025
@sarthak-d11
Copy link
Collaborator

Hi @ncpa0cpl,
I tried reproducing the issue using the reproducer you shared but couldn't replicate it. Additionally, I noticed from your npx react-native info output that you're currently on the old architecture (newArchEnabled: false). Could you please check if the issue persists when using the new architecture?

@sarthak-d11 sarthak-d11 added Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. labels Jan 14, 2025
@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@ncpa0cpl
Copy link
Author

did you perhaps ran the reproducer via the "Web" runtime in the snack? it does work properly there, but when using the android emulator the issue is occurring consistently, I have not seen it work properly even once, it is always as shown in the video

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 14, 2025
@ncpa0cpl
Copy link
Author

After some more investigating I think this is related to the Android version. I tested this on a emulator with android 10, 12 and 13. the behavior is different between them, 13 works as expected but on 10 and 12 the keypress event happens after the change

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. Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available
Projects
None yet
Development

No branches or pull requests

4 participants