Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Problems with ngModel input and Chinese IME #13617

Open
Gpia opened this issue Dec 23, 2015 · 7 comments
Open

Problems with ngModel input and Chinese IME #13617

Gpia opened this issue Dec 23, 2015 · 7 comments

Comments

@Gpia
Copy link

Gpia commented Dec 23, 2015

When I am using ngModel directive, I find something wrong when I use chinese words.

code


result1


result2

I searched this and find something called "CompositionEvent", I debuggered the code, and find someting in the angular source code.
source code

I do not want to get the result of input when typing is not completed.

Who can help me?

@Narretz
Copy link
Contributor

Narretz commented Dec 23, 2015

So you are using an IME to enter Chinese characters?

I don't know IME, so I don't know what the mistake is. Can you please describe what should happen, and what happens instead? The screenshots don't really explain it.

@Gpia
Copy link
Author

Gpia commented Dec 23, 2015

Yeah, I am using an IME to enter Chinese characters.
The problem is like this: I want to enter "你好" and I just press these keys “nihao” which are the keys on the keyboard that represent "你好" in Chinese pinyin input method. Before I press the enter key to choose the Chinese characters "你好", the English characters "ni'hao" are already read!
I mean that before I finish the input process, the callback of angular in the watch is called. So, the output of console is first "ni'hao", and then "你好". The callback function was called twice times, while just the second one is what I hoped.
This problem is not appeared on Firefox browser while it is on Google Chrome browser.
I found some relate things on the internet and wish you to handle the problem, thanks.
composition event on mozilla
composition event blog of somebody

@Narretz Narretz modified the milestones: 1.6.x, Purgatory Dec 31, 2015
@Narretz Narretz self-assigned this Dec 31, 2015
@Narretz Narretz changed the title Is there something wrong in the ngModel directive? Problems with ngModel input and Chinese IME Jan 4, 2016
@gkalpak
Copy link
Member

gkalpak commented Jan 21, 2016

Based on the last blog link you provided, it seems that (according to the spec) an input event should be fired after the composistionend event. Since we are calling the listener after both a compositionend and an input event, that could be the issue.

@Gpia, could you test if skipping the call to listener() on compositionend solves the problem ?

@Gpia
Copy link
Author

Gpia commented Mar 23, 2016

Yes,I tried according to what you said and It was ok. The result is right when I remove 'listener()' on compositionend. @gkalpak

@gkalpak
Copy link
Member

gkalpak commented Mar 23, 2016

Thx for getting back @Gpia.

I wonder if that compositionend event is any good. Maybe on some browsers. How could we test the behavior of compositionend + input events.

@Narretz, any ideas on this ?

@Narretz
Copy link
Contributor

Narretz commented Jun 9, 2016

The listener call on compositionend was introduced based on this: #6058
It looks like the general idea is not to update the input as long as it is in composition state. But some browser seem to not fire input on compositionend, so this call to listener was added. But it looks like this is also problematic.

@Narretz
Copy link
Contributor

Narretz commented Jun 9, 2016

I tried to reproduce the behavior with Windows 10, Simple chinese IME that comes with Windows, and Chrome 51.0.2704.84 m. I see the suggestions you have for "ni'hao", but I can't get the resulting 3 Chinese characters you have in your screenshot. I also don't see the intermediate updates (with Latin characters) that are logged for you. Maybe this is an issue with your specific IME.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants