react / react/react-native

TextInput onKeyPress fires after the onChange

Ouverte
#48,636 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Component: TextInput Needs: Attention Needs: Repro Newer Patch Available
Langage dominant
C++
Étoiles
127k
Forks
25.3k
Merge moyen
1 j 23 h
PR mergées (30 j)
4

Description

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:

https://github.com/user-attachments/assets/6e5b8cd5-6452-42a7-b315-54c911933a14

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le reproducteur Snack lié et la documentation de React Native TextInput, en vous concentrant sur l’ordre de onKeyPress et onChange sur Android. Suivez le cheminement d’événements pertinent de TextInput et ajoutez ou mettez à jour un test de régression si le dépôt en contient un ; le travail est considéré comme terminé lorsque l’ordre observé sur Android correspond au comportement documenté ou que la documentation reflète fidèlement l’implémentation.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
react-native
Domaine
mobile
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.