This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 403403 // ctrl.tagging pushes items to ctrl.items, so we only have empty val
404404 // for `item` if it is a detected duplicate
405405 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+ }
408413 }
409414 }
410415 // search ctrl.selected for dupes potentially caused by tagging and return early if found
455460 // Toggle dropdown
456461 ctrl . toggle = function ( e ) {
457462 if ( ctrl . open ) {
458- ctrl . close ( ) ;
463+ ctrl . close ( ) ;
459464 e . preventDefault ( ) ;
460- e . stopPropagation ( ) ;
465+ e . stopPropagation ( ) ;
461466 } else {
462467 ctrl . activate ( ) ;
463468 }
646651 }
647652 if ( tagged ) {
648653 $timeout ( function ( ) {
649- _searchInput . triggerHandler ( 'tagged' , ctrl . items ) ;
654+ _searchInput . triggerHandler ( 'tagged' ) ;
650655 var newItem = ctrl . search . replace ( KEY . MAP [ e . keyCode ] , '' ) . trim ( ) ;
651656 if ( ctrl . tagging . fct ) {
652657 newItem = ctrl . tagging . fct ( newItem ) ;
You can’t perform that action at this time.
0 commit comments