This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree 1 file changed +10
-5
lines changed 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 403
403
// ctrl.tagging pushes items to ctrl.items, so we only have empty val
404
404
// for `item` if it is a detected duplicate
405
405
if ( item === undefined ) return ;
406
- // create new item on the fly
407
- item = ctrl . tagging . fct !== undefined ? ctrl . tagging . fct ( ctrl . search ) : item . replace ( ctrl . taggingLabel , '' ) . trim ( ) ;
406
+ // create new item on the fly if we don't already have one;
407
+ // use tagging function if we have one, otherwise, push a string
408
+ if ( ctrl . tagging . fct !== undefined && item === undefined ) {
409
+ item = ctrl . tagging . fct ( ctrl . search ) ;
410
+ } else if ( typeof item === 'string' ) {
411
+ item = item . replace ( ctrl . taggingLabel , '' ) ;
412
+ }
408
413
}
409
414
}
410
415
// search ctrl.selected for dupes potentially caused by tagging and return early if found
455
460
// Toggle dropdown
456
461
ctrl . toggle = function ( e ) {
457
462
if ( ctrl . open ) {
458
- ctrl . close ( ) ;
463
+ ctrl . close ( ) ;
459
464
e . preventDefault ( ) ;
460
- e . stopPropagation ( ) ;
465
+ e . stopPropagation ( ) ;
461
466
} else {
462
467
ctrl . activate ( ) ;
463
468
}
646
651
}
647
652
if ( tagged ) {
648
653
$timeout ( function ( ) {
649
- _searchInput . triggerHandler ( 'tagged' , ctrl . items ) ;
654
+ _searchInput . triggerHandler ( 'tagged' ) ;
650
655
var newItem = ctrl . search . replace ( KEY . MAP [ e . keyCode ] , '' ) . trim ( ) ;
651
656
if ( ctrl . tagging . fct ) {
652
657
newItem = ctrl . tagging . fct ( newItem ) ;
You can’t perform that action at this time.
0 commit comments