Skip to content

Commit a23f004

Browse files
fixed declining tagging via returning null angular-ui#755
1 parent 948d383 commit a23f004

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/uiSelectMultipleDirective.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,16 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
290290
stashArr = stashArr.slice(1,stashArr.length);
291291
}
292292
newItem = $select.tagging.fct($select.search);
293-
newItem.isTag = true;
294-
// verify the the tag doesn't match the value of an existing item
295-
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, $select.tagging.fct($select.search) ); } ).length > 0 ) {
296-
return;
293+
294+
//Check if the tagging is declined
295+
if(newItem !== null){
296+
newItem.isTag = true;
297+
// verify the the tag doesn't match the value of an existing item
298+
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, $select.tagging.fct($select.search) ); } ).length > 0 ) {
299+
return;
300+
}
301+
newItem.isTag = true;
297302
}
298-
newItem.isTag = true;
299303
// handle newItem string and stripping dupes in tagging string context
300304
} else {
301305
// find any tagging items already in the $select.items array and store them
@@ -342,11 +346,15 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
342346
// dupe found, shave the first item
343347
if ( dupeIndex > -1 ) {
344348
items = items.slice(dupeIndex+1,items.length-1);
345-
} else {
349+
} else{
346350
items = [];
347-
items.push(newItem);
351+
//push only if the item is not null
352+
if(newItem !== null){
353+
items.push(newItem);
354+
}
348355
items = items.concat(stashArr);
349356
}
357+
350358
scope.$evalAsync( function () {
351359
$select.activeIndex = 0;
352360
$select.items = items;

0 commit comments

Comments
 (0)