Skip to content

Commit

Permalink
minor code adjustment for select mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yairEO committed Mar 16, 2024
1 parent 669ed81 commit 8cd82a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tagify.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,17 @@ Tagify.prototype = {
tagElm = tagElm || this.getLastTag()
opts = opts || {}

this.dropdown.hide()

var _s = this.settings,
editableElm = this.getTagTextNode(tagElm),
tagIdx = this.getNodeIndex(tagElm),
tagData = getSetTagData(tagElm),
_CB = this.events.callbacks,
isValid = true

// select mode is a bit different as clicking the tagify's content once will get into edit-mode if a value
// is already selected, and there cannot be a dropdown already open at this point.
_s.mode != 'select' && this.dropdown.hide()

if( !editableElm ){
Tagify.logger.warn('Cannot find element in Tag template: .', _s.classNames.tagTextSelector);
return;
Expand All @@ -522,7 +524,6 @@ Tagify.prototype = {
tagElm.classList.add( _s.classNames.tagEditing )

editableElm.addEventListener('click' , _CB.onEditTagClick.bind(this, tagElm))
editableElm.addEventListener('focus' , _CB.onEditTagFocus.bind(this, tagElm))
editableElm.addEventListener('blur' , _CB.onEditTagBlur.bind(this, this.getTagTextNode(tagElm)))
editableElm.addEventListener('input' , _CB.onEditTagInput.bind(this, editableElm))
editableElm.addEventListener('paste' , _CB.onEditTagPaste.bind(this, editableElm))
Expand Down Expand Up @@ -1642,7 +1643,7 @@ Tagify.prototype = {
},

removeTagsFromDOM(){
[].slice.call(this.getTagElms()).forEach(elm => elm.parentNode.removeChild(elm))
this.getTagElms().forEach(node => node.remove())
},

/**
Expand Down

0 comments on commit 8cd82a3

Please sign in to comment.