Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 24f2193

Browse files
author
ravishivt
committed
This is an update to the original fixes proposed in #647 without dist/ files based off the latest ui-select v0.14.9 release.
1 parent 3b1496c commit 24f2193

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/uiSelectController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ uis.controller('uiSelectCtrl',
223223
ctrl.setItemsFn(data);
224224
}else{
225225
if ( data !== undefined ) {
226-
var filteredItems = data.filter(function(i) {return selectedItems && selectedItems.indexOf(i) < 0;});
226+
var filteredItems = data.filter(function(i) {
227+
return selectedItems.every(function(selectedItem) {
228+
return !angular.equals(i, selectedItem);
229+
});
230+
});
227231
ctrl.setItemsFn(filteredItems);
228232
}
229233
}

src/uiSelectMultipleDirective.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,19 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
299299
stashArr = stashArr.slice(1,stashArr.length);
300300
}
301301
newItem = $select.tagging.fct($select.search);
302-
newItem.isTag = true;
303-
// verify the the tag doesn't match the value of an existing item
304-
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, $select.tagging.fct($select.search) ); } ).length > 0 ) {
302+
// verify the new tag doesn't match the value of a possible selection choice or an already selected item.
303+
if (
304+
stashArr.some(function (origItem) {
305+
return angular.equals(origItem, $select.tagging.fct($select.search));
306+
}) ||
307+
$select.selected.some(function (origItem) {
308+
return angular.equals(origItem, newItem);
309+
})
310+
) {
311+
scope.$evalAsync(function () {
312+
$select.activeIndex = 0;
313+
$select.items = items;
314+
});
305315
return;
306316
}
307317
newItem.isTag = true;

0 commit comments

Comments
 (0)