Skip to content

Commit 762bb8a

Browse files
committed
Update the scope when clearing a value from igCombo and test
1 parent bb3e96e commit 762bb8a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/igniteui-angular.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
// igCombo specific code for two way data binding
1717
$.ig.angular.igCombo = $.ig.angular.igCombo || {};
18-
$.ig.angular.igCombo.element = $.ig.angular.igCombo.element || "<input></input>";
19-
$.ig.angular.igCombo.events = [ "igcombotextchanged", "igcomboselectionchanged" ];
18+
$.ig.angular.igCombo.element = $.ig.angular.igCombo.element || "<div></div>";
19+
$.ig.angular.igCombo.events = [ "igcombofiltered", "igcomboselectionchanged" ];
2020

2121
// Mark watchers for discoverability
2222
function markWatcher(scope, controlName, attrs) {
@@ -159,6 +159,10 @@
159159
scope.$apply(function () {
160160
model.$setViewValue(comboValue(args.owner));
161161
});
162+
}).on("click", "div.ui-igcombo-clear", function () {
163+
scope.$apply(function () {
164+
model.$setViewValue([]);
165+
});
162166
}).one("$destroy", function () {
163167
unbinder();
164168
var index = $.inArray( setControlValue, model.$formatters );

test/e2e/scenarios.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -659,14 +659,14 @@ describe("my app", function() {
659659
util.executeScript(scope + ".combo.value1 = 2;");
660660
util.executeScript(scope + ".$apply();");
661661
expect(util.getResult(combo + '.igCombo("value")')).toBe(2);
662-
expect(util.getResult('$("#combo1").val()')).toBe("Chang");
662+
expect(util.getResult('$("#combo1").igCombo("textInput").val()')).toBe("Chang");
663663
util.executeScript('$("input[ng-model=\'combo.value1\']:eq(0)").val("5").trigger("input");');
664-
expect(util.getResult('$("#combo1").val()')).toBe("Chef Anton's Gumbo Mix");
664+
expect(util.getResult('$("#combo1").igCombo("textInput").val()')).toBe("Chef Anton's Gumbo Mix");
665665

666666
util.executeScript(scope + ".combo.value2 = [1];");
667667
util.executeScript(scope + ".$apply();");
668668
expect(util.getResult(combo2 + '.igCombo("value")[0]')).toBe(1);
669-
expect(util.getResult('$("#combo2").val()')).toBe("Chai");
669+
expect(util.getResult('$("#combo2").igCombo("textInput").val()')).toBe("Chai");
670670
});
671671

672672
it("should set model on clear", function() {
@@ -682,17 +682,17 @@ describe("my app", function() {
682682
});
683683

684684
it("should update model on change of combo input", function() {
685-
util.executeScript(combo + ".focus();");
685+
util.executeScript(combo + ".igCombo('textInput').focus();");
686686
//check scope value remains unchanged during search entry
687-
expect(util.getResult('typeInInputWrap("Chang", ' + combo + ', "combo.value1");')).toBe(false);
687+
expect(util.getResult('typeInInputWrap("Chang", ' + combo3 + '.igCombo("textInput")' + ', "combo.value1");')).toBe(false);
688688
// wait for sleep resolve:
689689
expect(browser.driver.sleep(250)).toBe(undefined); //util.getResult(combo + '.igCombo("option", "delayInputChangeProcessing");')
690690
expect(util.getResult(scope + ".combo.value1")).toBe(2);
691691
});
692692

693693
it("should update combo value when allowCustomValue is true", function(){
694-
util.executeScript(combo3 + ".focus();");
695-
expect(util.getResult('typeInInputWrap("customValue1", ' + combo3 + ', "combo.value1");')).toBe(false);
694+
util.executeScript(combo3 + ".igCombo('textInput').focus();");
695+
expect(util.getResult('typeInInputWrap("customValue1", ' + combo3 + '.igCombo("textInput")' + ', "combo.value1");')).toBe(false);
696696
expect(browser.driver.sleep(250)).toBe(undefined);
697697
util.executeScript(combo3 + ".igCombo('comboWrapper').find('.ui-igcombo-button').click();");
698698
expect(util.getResult(combo3 + '.igCombo("value")[0]')).toBe("customValue1");
@@ -702,7 +702,12 @@ describe("my app", function() {
702702
util.executeScript(scope + ".northwind = [{'ProductID': 21, 'ProductName': 'Strawberry'}];");
703703
util.executeScript(scope + ".combo.value2 = [21];");
704704
util.executeScript(scope + ".$apply();");
705-
expect(util.getResult('$("#combo2").val()')).toBe("Strawberry");
705+
expect(util.getResult('$("#combo2").igCombo("textInput").val()')).toBe("Strawberry");
706+
});
707+
708+
it("should set model on clear when allowCustomValue is true", function () {
709+
util.executeScript(combo3 + ".igCombo('comboWrapper').find('.ui-igcombo-clear').click();");
710+
expect(util.getResult(scope + ".combo.value1.length")).toBe(0);
706711
});
707712
});
708713

0 commit comments

Comments
 (0)