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

Fix for https://github.com/angular-ui/ui-select/pull/327#issuecomment-65960779 #484

Merged
merged 2 commits into from
Dec 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-select",
"version": "0.9.1",
"version": "0.9.2",
"homepage": "https://github.com/angular-ui/ui-select",
"authors": [
"AngularUI"
Expand Down
2 changes: 1 addition & 1 deletion dist/select.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* ui-select
* http://github.com/angular-ui/ui-select
* Version: 0.9.1 - 2014-12-03T16:41:44.801Z
* Version: 0.9.2 - 2014-12-08T14:55:46.402Z
* License: MIT
*/

Expand Down
33 changes: 27 additions & 6 deletions dist/select.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* ui-select
* http://github.com/angular-ui/ui-select
* Version: 0.9.1 - 2014-12-03T16:41:44.798Z
* Version: 0.9.2 - 2014-12-08T14:55:46.399Z
* License: MIT
*/

Expand Down Expand Up @@ -623,7 +623,7 @@
if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
// make sure there is a new value to push via tagging
if ( ctrl.search.length > 0 ) {
ctrl.select(null, true);
ctrl.select(undefined, true);
_searchInput.triggerHandler('tagged');
}
}
Expand Down Expand Up @@ -712,7 +712,7 @@
}
// verify the the tag doesn't match the value of an existing item from
// the searched data set
if ( stashArr.filter( function (origItem) { return origItem.toUpperCase() === ctrl.search.toUpperCase(); }).length > 0 ) {
if ( _findCaseInsensitiveDupe(stashArr) ) {
// if there is a tag from prev iteration, strip it / queue the change
// and return early
if ( hasTag ) {
Expand All @@ -724,7 +724,7 @@
}
return;
}
if ( ctrl.selected.filter( function (selection) { return selection.toUpperCase() === ctrl.search.toUpperCase(); } ).length > 0 ) {
if ( _findCaseInsensitiveDupe(stashArr) ) {
// if there is a tag from prev iteration, strip it
if ( hasTag ) {
ctrl.items = stashArr.slice(1,stashArr.length);
Expand Down Expand Up @@ -760,6 +760,20 @@
});
});

function _findCaseInsensitiveDupe(arr) {
if ( arr === undefined || ctrl.search === undefined ) {
return false;
}
var hasDupe = arr.filter( function (origItem) {
if ( ctrl.search.toUpperCase() === undefined ) {
return false;
}
return origItem.toUpperCase() === ctrl.search.toUpperCase();
}).length > 0;

return hasDupe;
}

function _findApproxDupe(haystack, needle) {
var tempArr = angular.copy(haystack);
var dupeIndex = -1;
Expand Down Expand Up @@ -845,7 +859,14 @@
attrs.multiple.toLowerCase() === 'true'
);

$select.closeOnSelect = (angular.isDefined(attrs.closeOnSelect) && attrs.closeOnSelect.toLowerCase() === 'false') ? false : uiSelectConfig.closeOnSelect;
$select.closeOnSelect = function() {
if (angular.isDefined(attrs.closeOnSelect)) {
return $parse(attrs.closeOnSelect)();
} else {
return uiSelectConfig.closeOnSelect;
}
}();

$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);

Expand Down Expand Up @@ -1221,7 +1242,7 @@
attrs.$observe('placeholder', function(placeholder) {
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
});

$select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;

if($select.multiple){
Expand Down
2 changes: 1 addition & 1 deletion dist/select.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/select.min.js
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": {
"url": "git://github.com/angular-ui/ui-select.git"
},
"version": "0.9.1",
"version": "0.9.2",
"devDependencies": {
"bower": "~1.3",
"del": "~0.1.1",
Expand Down
22 changes: 18 additions & 4 deletions src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@
if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
// make sure there is a new value to push via tagging
if ( ctrl.search.length > 0 ) {
ctrl.select(null, true);
ctrl.select(undefined, true);
_searchInput.triggerHandler('tagged');
}
}
Expand Down Expand Up @@ -704,7 +704,7 @@
}
// verify the the tag doesn't match the value of an existing item from
// the searched data set
if ( stashArr.filter( function (origItem) { return origItem.toUpperCase() === ctrl.search.toUpperCase(); }).length > 0 ) {
if ( _findCaseInsensitiveDupe(stashArr) ) {
// if there is a tag from prev iteration, strip it / queue the change
// and return early
if ( hasTag ) {
Expand All @@ -716,7 +716,7 @@
}
return;
}
if ( ctrl.selected.filter( function (selection) { return selection.toUpperCase() === ctrl.search.toUpperCase(); } ).length > 0 ) {
if ( _findCaseInsensitiveDupe(stashArr) ) {
// if there is a tag from prev iteration, strip it
if ( hasTag ) {
ctrl.items = stashArr.slice(1,stashArr.length);
Expand Down Expand Up @@ -752,6 +752,20 @@
});
});

function _findCaseInsensitiveDupe(arr) {
if ( arr === undefined || ctrl.search === undefined ) {
return false;
}
var hasDupe = arr.filter( function (origItem) {
if ( ctrl.search.toUpperCase() === undefined ) {
return false;
}
return origItem.toUpperCase() === ctrl.search.toUpperCase();
}).length > 0;

return hasDupe;
}

function _findApproxDupe(haystack, needle) {
var tempArr = angular.copy(haystack);
var dupeIndex = -1;
Expand Down Expand Up @@ -1220,7 +1234,7 @@
attrs.$observe('placeholder', function(placeholder) {
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
});

$select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;

if($select.multiple){
Expand Down