Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
fix(tagsInput): Ignore addFromAutocompleteOnly on input-blur
Browse files Browse the repository at this point in the history
Ignore the addFromAutocompleteOnly option on the input-blur event and
always set the element's validity.
  • Loading branch information
just-boris authored and mbenford committed Dec 16, 2014
1 parent 9ad32fb commit e4767c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
13 changes: 4 additions & 9 deletions src/tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,14 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig)
})
.on('input-focus', function() {
element.triggerHandler('focus');

ngModelCtrl.$setValidity('leftoverText', true);
})
.on('input-blur', function() {
element.triggerHandler('blur');

if (!options.addFromAutocompleteOnly) {
if (options.addOnBlur) {
tagList.addText(scope.newTag.text);
}

setElementValidity();
if (options.addOnBlur && !options.addFromAutocompleteOnly) {
tagList.addText(scope.newTag.text);
}
element.triggerHandler('blur');
setElementValidity();
})
.on('input-keydown', function(event) {
var key = event.keyCode,
Expand Down
12 changes: 0 additions & 12 deletions test/tags-input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1287,18 +1287,6 @@ describe('tags-input directive', function() {
// Assert
expect(isolateScope.tags).toEqual([]);
});

it('does not make the element invalid when it loses focus and there is any leftover text', function() {
// Arrange
isolateScope.newTag.text = 'foo';

// Act
isolateScope.events.trigger('input-blur');

// Assert
expect($scope.form.tags.$valid).toBe(true);
expect($scope.form.tags.$error.leftoverText).toBeFalsy();
});
});
});

Expand Down

0 comments on commit e4767c2

Please sign in to comment.