diff --git a/src/select.js b/src/select.js index c450b7a3d..91923a165 100644 --- a/src/select.js +++ b/src/select.js @@ -1109,8 +1109,13 @@ if (oldValue != newValue) ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters }); + $select.firstPass = true; // so the form doesn't get dirty as soon as it loads scope.$watchCollection('$select.selected', function() { - ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes + if (!$select.firstPass) { + ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes + } else { + $select.firstPass = false; + } }); focusser.prop('disabled', true); //Focusser isn't needed if multiple }else{ diff --git a/test/select.spec.js b/test/select.spec.js index 70b4acd14..37f656a18 100644 --- a/test/select.spec.js +++ b/test/select.spec.js @@ -404,7 +404,7 @@ describe('ui-select tests', function() { beforeEach(function() { disablePerson({ disableAttr : 'inactive', - disableBool : true, + disableBool : true }); this.el = createUiSelect({ disabled: 'person.inactive' @@ -437,7 +437,7 @@ describe('ui-select tests', function() { beforeEach(function() { disablePerson({ disableAttr : 'active', - disableBool : false, + disableBool : false }); this.el = createUiSelect({ disabled: '!person.active' @@ -1123,13 +1123,13 @@ describe('ui-select tests', function() { expect(el.find('.ui-select-match-item').length).toBe(0); }); - it('should set model as an empty array if ngModel isnt defined', function () { + it('should set model as an empty array if ngModel isnt defined after an item is selected', function () { // scope.selection.selectedMultiple = []; var el = createUiSelectMultiple(); - + expect(scope.selection.selectedMultiple instanceof Array).toBe(false); + clickItem(el, 'Samantha'); expect(scope.selection.selectedMultiple instanceof Array).toBe(true); - }); it('should render initial selected items', function() {