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

Commit

Permalink
fix(tagsInput): Added event trigger to tryAdd
Browse files Browse the repository at this point in the history
Changed tryAdd method to trigger an input-changed event after clearing
the input field so the autocomplete directive can hide the suggestions
box properly.

Closes #26.
  • Loading branch information
mbenford committed Dec 1, 2013
1 parent 6306d5c commit 84bb916
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
3 changes: 0 additions & 3 deletions src/auto-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ angular.module('tags-input').directive('autoComplete', function($document, $time
};

tagsInput
.on('tag-added', function() {
suggestionList.reset();
})
.on('input-changed', function(value) {
if (value) {
suggestionList.load(value);
Expand Down
1 change: 1 addition & 0 deletions src/tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ angular.module('tags-input').directive('tagsInput', function(configuration) {
}

$scope.newTag = '';
events.trigger('input-changed', '');
changed = true;
}
return changed;
Expand Down
11 changes: 0 additions & 11 deletions test/auto-complete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,6 @@ describe('autocomplete-directive', function() {
expect(isSuggestionsBoxVisible()).toBe(false);
});

it('hides the suggestion box when a tag is added', function() {
// Arrange
suggestionList.show();

// Act
eventHandlers['tag-added']();

// Assert
expect(isSuggestionsBoxVisible()).toBe(false);
});

it('adds the selected suggestion to the input field when the enter key is pressed and the suggestions box is visible', function() {
// Arrange
loadSuggestions(['Item1', 'Item2']);
Expand Down

0 comments on commit 84bb916

Please sign in to comment.