TextInput order of events are inconsistent between iOS and Android
See original GitHub issueTextInput 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
beforeselection 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
On Android, the events are in the following order:
- change text
- selection change
- onKeyPress (See #18262)
Steps to Reproduce
Issue Analytics
- State:
- Created 6 years ago
- Reactions:25
- Comments:15
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
same issue, please fix it
FWIW, I made this Snack to help debug the
onChangeText
/onKeyPress
before discovering this open issue: https://snack.expo.io/BJM4Rf9RfOn Android this logs in the following order:
onChange
onChangeText
onKeyPress
Env: