Change event fires extra times before IME composition ends
See original GitHub issueExtra details
- Similar discussion with extra details and reproducing analysis: https://github.com/facebook/react/issues/8683
- Previous attempt to fix it: https://github.com/facebook/react/pull/8438 (includes some unit tests, but sufficient to be confident in the fix)
Original Issue
When I was trying this example from https://facebook.github.io/react/blog/2013/11/05/thinking-in-react.html, any Chinese characters inputted by Chinese pinyin input method would fire too many renders like:
Actually I would expect those not to fire before I confirm the Chinese character.
Then I tried another kind of input method - wubi input method, I got this:
It’s weird too. So I did a test in jQuery:
Only after I press the space bar to confirm the character, the keyup
event would fire.
I know it might be different between the implementation of jQuery keyup
and react onChange
, but I would expect the way how jQuery keyup
handles Chinese characters instead of react’s onChange
.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:29
- Comments:51 (8 by maintainers)
Top Results From Across the Web
Why does jQuery on change event fire multiple times?
But the event is firing 1 extra time for each time the select list changes. (First time it fires once, then twice, then...
Read more >Element: compositionend event - Web APIs | MDN
The compositionend event is fired when a text composition system such as an input method editor completes or cancels the current composition ......
Read more >Handling Events - React
React events are named using camelCase, rather than lowercase. With JSX you pass a function as the event handler, rather than a string....
Read more >Climate Change Indicators: Weather and Climate | US EPA
Scientific studies indicate that extreme weather events such as heat waves and ... However, changes in observation methods over time make it ...
Read more >Online Learning: A Panacea in the Time of COVID-19 Crisis
Many academic institutions that were earlier reluctant to change their traditional pedagogical approach had no option but to shift entirely to online teaching– ......
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
Hello, Facebook guys, in fact this issue causes a SERIOUS problem: we can’t update input asynchronously with Chinese input. For example, we can’t use meteor reactive datasources or stores like redux, because they all feedback update asynchronously. Here is a simplest example to show this problem, it use setTimeout to do async update: https://jsfiddle.net/liyatang/bq6oss6z/1/
I really hope you can fix this quickly, so that we won’t waste efforts to workaround it here and there and over and over again.
Thanks.
Here is my workaround. If anyone face the same problem, you can have a look
There is a tricky solution for Chrome v53. To call the handlechange after
compositionend
is fired.check the demo here: https://jsfiddle.net/eyesofkids/dcxvas28/11/