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.

Change event fires extra times before IME composition ends

See original GitHub issue

Extra details


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:

screen shot 2015-05-21 at 14 04 36

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:

screen shot 2015-05-21 at 14 17 15

It’s weird too. So I did a test in jQuery:

screen shot 2015-05-21 at 14 05 12

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:open
  • Created 8 years ago
  • Reactions:29
  • Comments:51 (8 by maintainers)

github_iconTop GitHub Comments

30reactions
zhaoyao91commented, Aug 5, 2016

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

9reactions
eyesofkidscommented, Oct 5, 2016

There is a tricky solution for Chrome v53. To call the handlechange after compositionend is fired.

handleComposition  = (event) => {

    if(event.type === 'compositionend'){
      onComposition = false

      //fire change method to update for Chrome v53
      this.handleChange(event)

    } else{
      onComposition = true
    }
  }

check the demo here: https://jsfiddle.net/eyesofkids/dcxvas28/11/

Read more comments on GitHub >

github_iconTop 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 >

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