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

Commit 7c9dfc1

Browse files
author
Brian Feister
committed
Merge pull request #484 from brianfeister/master
Fix for #327 (comment)
2 parents 90b7b14 + 011105b commit 7c9dfc1

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ui-select",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"homepage": "https://github.com/angular-ui/ui-select",
55
"authors": [
66
"AngularUI"

dist/select.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.9.1 - 2014-12-03T16:41:44.801Z
4+
* Version: 0.9.2 - 2014-12-08T14:55:46.402Z
55
* License: MIT
66
*/
77

dist/select.js

100644100755
+27-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.9.1 - 2014-12-03T16:41:44.798Z
4+
* Version: 0.9.2 - 2014-12-08T14:55:46.399Z
55
* License: MIT
66
*/
77

@@ -623,7 +623,7 @@
623623
if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
624624
// make sure there is a new value to push via tagging
625625
if ( ctrl.search.length > 0 ) {
626-
ctrl.select(null, true);
626+
ctrl.select(undefined, true);
627627
_searchInput.triggerHandler('tagged');
628628
}
629629
}
@@ -712,7 +712,7 @@
712712
}
713713
// verify the the tag doesn't match the value of an existing item from
714714
// the searched data set
715-
if ( stashArr.filter( function (origItem) { return origItem.toUpperCase() === ctrl.search.toUpperCase(); }).length > 0 ) {
715+
if ( _findCaseInsensitiveDupe(stashArr) ) {
716716
// if there is a tag from prev iteration, strip it / queue the change
717717
// and return early
718718
if ( hasTag ) {
@@ -724,7 +724,7 @@
724724
}
725725
return;
726726
}
727-
if ( ctrl.selected.filter( function (selection) { return selection.toUpperCase() === ctrl.search.toUpperCase(); } ).length > 0 ) {
727+
if ( _findCaseInsensitiveDupe(stashArr) ) {
728728
// if there is a tag from prev iteration, strip it
729729
if ( hasTag ) {
730730
ctrl.items = stashArr.slice(1,stashArr.length);
@@ -760,6 +760,20 @@
760760
});
761761
});
762762

763+
function _findCaseInsensitiveDupe(arr) {
764+
if ( arr === undefined || ctrl.search === undefined ) {
765+
return false;
766+
}
767+
var hasDupe = arr.filter( function (origItem) {
768+
if ( ctrl.search.toUpperCase() === undefined ) {
769+
return false;
770+
}
771+
return origItem.toUpperCase() === ctrl.search.toUpperCase();
772+
}).length > 0;
773+
774+
return hasDupe;
775+
}
776+
763777
function _findApproxDupe(haystack, needle) {
764778
var tempArr = angular.copy(haystack);
765779
var dupeIndex = -1;
@@ -845,7 +859,14 @@
845859
attrs.multiple.toLowerCase() === 'true'
846860
);
847861

848-
$select.closeOnSelect = (angular.isDefined(attrs.closeOnSelect) && attrs.closeOnSelect.toLowerCase() === 'false') ? false : uiSelectConfig.closeOnSelect;
862+
$select.closeOnSelect = function() {
863+
if (angular.isDefined(attrs.closeOnSelect)) {
864+
return $parse(attrs.closeOnSelect)();
865+
} else {
866+
return uiSelectConfig.closeOnSelect;
867+
}
868+
}();
869+
849870
$select.onSelectCallback = $parse(attrs.onSelect);
850871
$select.onRemoveCallback = $parse(attrs.onRemove);
851872

@@ -1221,7 +1242,7 @@
12211242
attrs.$observe('placeholder', function(placeholder) {
12221243
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
12231244
});
1224-
1245+
12251246
$select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;
12261247

12271248
if($select.multiple){

dist/select.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js

100644100755
+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"repository": {
77
"url": "git://github.com/angular-ui/ui-select.git"
88
},
9-
"version": "0.9.1",
9+
"version": "0.9.2",
1010
"devDependencies": {
1111
"bower": "~1.3",
1212
"del": "~0.1.1",

src/select.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@
615615
if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
616616
// make sure there is a new value to push via tagging
617617
if ( ctrl.search.length > 0 ) {
618-
ctrl.select(null, true);
618+
ctrl.select(undefined, true);
619619
_searchInput.triggerHandler('tagged');
620620
}
621621
}
@@ -704,7 +704,7 @@
704704
}
705705
// verify the the tag doesn't match the value of an existing item from
706706
// the searched data set
707-
if ( stashArr.filter( function (origItem) { return origItem.toUpperCase() === ctrl.search.toUpperCase(); }).length > 0 ) {
707+
if ( _findCaseInsensitiveDupe(stashArr) ) {
708708
// if there is a tag from prev iteration, strip it / queue the change
709709
// and return early
710710
if ( hasTag ) {
@@ -716,7 +716,7 @@
716716
}
717717
return;
718718
}
719-
if ( ctrl.selected.filter( function (selection) { return selection.toUpperCase() === ctrl.search.toUpperCase(); } ).length > 0 ) {
719+
if ( _findCaseInsensitiveDupe(stashArr) ) {
720720
// if there is a tag from prev iteration, strip it
721721
if ( hasTag ) {
722722
ctrl.items = stashArr.slice(1,stashArr.length);
@@ -752,6 +752,20 @@
752752
});
753753
});
754754

755+
function _findCaseInsensitiveDupe(arr) {
756+
if ( arr === undefined || ctrl.search === undefined ) {
757+
return false;
758+
}
759+
var hasDupe = arr.filter( function (origItem) {
760+
if ( ctrl.search.toUpperCase() === undefined ) {
761+
return false;
762+
}
763+
return origItem.toUpperCase() === ctrl.search.toUpperCase();
764+
}).length > 0;
765+
766+
return hasDupe;
767+
}
768+
755769
function _findApproxDupe(haystack, needle) {
756770
var tempArr = angular.copy(haystack);
757771
var dupeIndex = -1;
@@ -1220,7 +1234,7 @@
12201234
attrs.$observe('placeholder', function(placeholder) {
12211235
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
12221236
});
1223-
1237+
12241238
$select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;
12251239

12261240
if($select.multiple){

0 commit comments

Comments
 (0)