question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextInput order of events are inconsistent between iOS and Android

See original GitHub issue

TextInput event order are different for iOS and Android.

This inconsistency make certain operations hard to archive on Android:

  • Detect backspace key on empty text input to delete the component. If only 1 character is left in the text, pressing backspace key will delete the text first before we process which key is pressed, which will make us assume that the text input is empty.
  • Processing text on change text event before selection change event can cause crash due to invalid selection.

Environment

Tested on Expo 25.0.0/0.52.0, but original issue happen in 0.53.3 as well, Likely exist in 0.54.0

Expected Behavior

I think iOS order of events make the most sense and I hope Android can follow the suit.

Actual Behavior

The event in question are onChangeText(), onSelectionChange() and onKeyPress().

On iOS, the events are in the following order:

  • key press
  • selection change
  • change text

screenshot 2018-03-06 17 12 21

On Android, the events are in the following order:

  • change text
  • selection change
  • onKeyPress (See #18262)

screenshot 2018-03-06 17 12 27

Steps to Reproduce

https://snack.expo.io/Hk2qtCouf

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:25
  • Comments:15

github_iconTop GitHub Comments

4reactions
ThienMDcommented, Mar 19, 2019

same issue, please fix it

4reactions
richgilbankcommented, May 31, 2018

FWIW, I made this Snack to help debug the onChangeText/onKeyPress before discovering this open issue: https://snack.expo.io/BJM4Rf9Rf

On Android this logs in the following order:

  • onChange
  • onChangeText
  • onKeyPress

Env:

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 8.9.4
  Yarn: 1.5.1
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.1 AI-173.4670197

Packages: (wanted => installed)
  react: 16.3.0-alpha.1 => 16.3.0-alpha.1
  react-native: https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz => 0.54.2
Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between onEndEditing and onBlur? - Stack Overflow
Both onBlur and onEndEditing get an event. On iOS both of these seem to do the exact same thing, and the event has...
Read more >
TextInput with inconsistent text alignment
When Published and display in Android Apps, it is correctly displayed and show with proper alignment. I assume it is BUGS in Windows...
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >
Kotlin and Android From Scratch Flashcards | Quizlet
Android studio kotlin beginner study guide Learn with flashcards, games, ... correctly calls the function, below, and passes it valid input arguments?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found