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

Commit 056ab96

Browse files
dimircAsimov4
authored andcommitted
fix(tagging): allow to decline tag creation
1 parent 145af05 commit 056ab96

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/select.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
if ( ctrl.taggingLabel === false ) {
394394
if ( ctrl.activeIndex < 0 ) {
395395
item = ctrl.tagging.fct !== undefined ? ctrl.tagging.fct(ctrl.search) : ctrl.search;
396-
if ( angular.equals( ctrl.items[0], item ) ) {
396+
if (!item || angular.equals( ctrl.items[0], item ) ) {
397397
return;
398398
}
399399
} else {
@@ -412,6 +412,7 @@
412412
// use tagging function if we have one
413413
if ( ctrl.tagging.fct !== undefined && typeof item === 'string' ) {
414414
item = ctrl.tagging.fct(ctrl.search);
415+
if (!item) return;
415416
// if item type is 'string', apply the tagging label
416417
} else if ( typeof item === 'string' ) {
417418
// trim the trailing space
@@ -668,7 +669,7 @@
668669
if ( ctrl.tagging.fct ) {
669670
newItem = ctrl.tagging.fct( newItem );
670671
}
671-
ctrl.select( newItem, true);
672+
if (newItem) ctrl.select(newItem, true);
672673
});
673674
}
674675
}
@@ -751,6 +752,7 @@
751752
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, ctrl.tagging.fct(ctrl.search) ); } ).length > 0 ) {
752753
return;
753754
}
755+
newItem.isTag = true;
754756
// handle newItem string and stripping dupes in tagging string context
755757
} else {
756758
// find any tagging items already in the ctrl.items array and store them

0 commit comments

Comments
 (0)