From a4e6d962d78b26f5112d48c4f88c1e6234d0cae7 Mon Sep 17 00:00:00 2001 From: Chia-liang Kao Date: Tue, 29 Oct 2013 00:42:47 +0800 Subject: feat(input): hold listener during text composition When composing text in CJKV, intermediate buffer for unfinished text should not be updating the bound scope variables. Closes #4684 --- src/ng/directive/input.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ng/directive/input.js') diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index e264db38..ea4d84f4 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -392,8 +392,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 -- cgit v1.2.3