diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 825b008738..3eafb141db 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -315,6 +315,21 @@ describe('typeahead tests', function() { expect($scope.form.input.$error.parse).toBeFalsy(); }); + it('should go through other validators after blur for typeahead-editable="false"', function () { + var element = prepareInputEl( + '
'); + var inputEl = findInput(element); + + changeInputValueTo(element, 'not in matches'); + expect($scope.result).toEqual(undefined); + expect(inputEl.val()).toEqual('not in matches'); + inputEl.blur(); // input loses focus + expect($scope.result).toEqual(undefined); + expect($scope.form.input.$error.required).toBeTruthy(); + }); + it('should clear view value when no value selected for typeahead-editable="false" typeahead-select-on-blur="false"', function () { var element = prepareInputEl(''); var inputEl = findInput(element); diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 14169c6371..05a59234a0 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -441,7 +441,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap }); } if (!isEditable && modelCtrl.$error.editable) { - modelCtrl.$viewValue = ''; + modelCtrl.$setViewValue(); // Reset validity as we are clearing modelCtrl.$setValidity('editable', true); modelCtrl.$setValidity('parse', true);