Skip to content

Commit be20e58

Browse files
caitpSebastien Armand - sa250111
authored and
Sebastien Armand - sa250111
committed
fix(input): setViewValue on compositionend
Because of a4e6d96, model is not updated on input/change between the compositionstart and compositionend events. Unfortunately, the compositionend event does not always happen prior to an input/change event. This changeset calls the listener function to update the model after a compositionend event is received. Closes angular#6058 Closes angular#5433
1 parent 4f09a51 commit be20e58

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/ng/directive/input.js

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
447447

448448
element.on('compositionend', function() {
449449
composing = false;
450+
listener();
450451
});
451452
}
452453

test/ng/directive/inputSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,17 @@ describe('input', function() {
509509
});
510510
}
511511

512+
it('should update the model on "compositionend"', function() {
513+
compileInput('<input type="text" ng-model="name" name="alias" />');
514+
if (!(msie < 9)) {
515+
browserTrigger(inputElm, 'compositionstart');
516+
changeInputValueTo('caitp');
517+
expect(scope.name).toBeUndefined();
518+
browserTrigger(inputElm, 'compositionend');
519+
expect(scope.name).toEqual('caitp');
520+
}
521+
});
522+
512523
describe('"change" event', function() {
513524
function assertBrowserSupportsChangeEvent(inputEventSupported) {
514525
// Force browser to report a lack of an 'input' event

0 commit comments

Comments
 (0)