Skip to content

Commit e759e46

Browse files
committed
feat(ngModelController): hold listener during text composition
When composing text in CJKV, intermediate buffer for unfinished text should not be updating the bound scope variables. Closes angular#4684
1 parent 18ae985 commit e759e46

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ng/directive/input.js

+13
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,21 @@ var inputType = {
393393

394394

395395
function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
396+
// In composition mode, users are still inputing intermediate text buffer,
397+
// hold the listener until composition is done.
398+
// More about composition events: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
399+
var composing = false;
400+
401+
element.on('compositionstart', function() {
402+
composing = true;
403+
});
404+
405+
element.on('compositionend', function() {
406+
composing = false;
407+
});
396408

397409
var listener = function() {
410+
if (composing) return;
398411
var value = element.val();
399412

400413
// By default we will trim the value

0 commit comments

Comments
 (0)