Skip to content

Commit 0bd90dc

Browse files
committed
editors binding fix, tests with 1.4+, version bump
- fixing a bug where the model rejects the editor value when it's actually set (because the monitored view value was previously ignored once) - editor model formatter update to work with old editors as well - adding test and updating angular version
1 parent a5c1d5c commit 0bd90dc

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"homepage": "http://igniteui.com",
66
"dependencies": {
7-
"angular": "1.2.x",
7+
"angular": "1.4.x",
88
"angular-route": "1.2.x",
99
"angular-loader": "1.2.x",
1010
"angular-mocks": "~1.2.x",

src/igniteui-angular.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!@license
2-
* Ignite UI directives for AngularJS 1.1.3
2+
* Ignite UI directives for AngularJS 1.1.4
33
* https://github.com/IgniteUI/igniteui-angular
44
*
55
* Copyright (c) 2014-2016 Infragistics, Inc.
@@ -85,17 +85,24 @@
8585
var controlName = attrs["data-ig-control-name"];
8686

8787
function setControlValue(value) {
88-
element.data(controlName).value(value);
89-
return element.data(controlName).displayValue();
88+
var editor = element.data(controlName),
89+
displayFunc = editor.displayValue || editor.text;
90+
91+
editor.value(value);
92+
return displayFunc.call(editor);
9093
}
9194
function parseValue() {
92-
// parse value off of DOM through the control value
95+
//"parse" through the control value, ensure no-flicker with formatted values
96+
//model controller will attempt to set the edit text (not actual value) to the model. Only allow the actual control value to update.
97+
//Can be extended in the future with "immediate" update mode and attempt to provide the to-be value
9398
return element.data(controlName).value();
9499
}
95100
if (controlName) {
96101
$.ig.angular[controlName].events = [controlName.toLowerCase() + "valuechanged"];
97102
element.on($.ig.angular[controlName].events.join(' '), function (event, args) {
98103
scope.$apply(function () {
104+
// force newer versions of ngModelController(1.3.0+) to update, since we kept the control value while in input was changing
105+
model.$$lastCommittedViewValue = null;
99106
model.$setViewValue(args.owner.value());
100107
});
101108
}).one('$destroy', function () {

test/e2e/scenarios.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,5 +617,12 @@ describe('my app', function() {
617617
it("Text should be initialized", function() {
618618
util.isInitialized("text1", "igTextEditor");
619619
});
620+
it("Text should updated model correctly", function() {
621+
var textInModel = 'angular.element("#text1").scope().editors.text;';
622+
util.executeScript('$("#text1").trigger("focus").val("newText").trigger("input");');// kickstart ngModel, editor is still in edit mode though
623+
expect(util.getResult(textInModel)).toBe("some more text"); // should remain unchanged
624+
util.executeScript('$("#text1").trigger("blur");');
625+
expect(util.getResult(textInModel)).toBe("newText");
626+
});
620627
});
621628
});

0 commit comments

Comments
 (0)