Skip to content

Commit

Permalink
feat(ngModelController): hold listener during text composition
Browse files Browse the repository at this point in the history
When composing text in CJKV, intermediate buffer for unfinished text should not
be updating the bound scope variables.

Closes angular#4684
  • Loading branch information
clkao committed Oct 28, 2013
1 parent 18ae985 commit e759e46
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,21 @@ var inputType = {


function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
// In composition mode, users are still inputing intermediate text buffer,
// hold the listener until composition is done.
// More about composition events: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
var composing = false;

element.on('compositionstart', function() {
composing = true;
});

element.on('compositionend', function() {
composing = false;
});

var listener = function() {
if (composing) return;
var value = element.val();

// By default we will trim the value
Expand Down

0 comments on commit e759e46

Please sign in to comment.