Skip to content

Commit 8a9d01c

Browse files
committed
fixes #1469 - "add" event not fired in mix-mode
1 parent 661b768 commit 8a9d01c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/tagify.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,21 +1470,23 @@ Tagify.prototype = {
14701470
return this.prefixedTextToTag(tagsData[0])
14711471
}
14721472

1473-
var frag = document.createDocumentFragment()
1473+
var frag = document.createDocumentFragment();
1474+
var addedTags = [];
14741475

14751476
tagsData.forEach(tagData => {
14761477
const newTagNode = this.prepareNewTagNode(tagData)
14771478
frag.appendChild(newTagNode.tagElm)
14781479
this.insertAfterTag(newTagNode.tagElm)
14791480
this.postProcessNewTagNode(newTagNode.tagElm, newTagNode.tagData)
1481+
addedTags.push({tagElm: newTagNode.tagElm, tagData: newTagNode.tagData})
14801482
})
14811483

1482-
this.appendMixTags(frag)
1484+
this.appendMixTags(frag, addedTags)
14831485

14841486
return frag.children
14851487
},
14861488

1487-
appendMixTags( node ) {
1489+
appendMixTags( node, addedTags ) {
14881490
var selection = !!this.state.selection;
14891491

14901492
// if "selection" exists, assumes intention of inecting the new tag at the last
@@ -1502,6 +1504,8 @@ Tagify.prototype = {
15021504

15031505
this.updateValueByDOMTags() // updates internal "this.value"
15041506
this.update() // updates original input/textarea
1507+
1508+
this.trigger('add', {tags: addedTags || node.children})
15051509
}
15061510
},
15071511

@@ -1542,6 +1546,8 @@ Tagify.prototype = {
15421546

15431547
this.postProcessNewTagNode(tagElm, newTag.tagData)
15441548

1549+
this.trigger('add', {tag: newTag, data:tagData})
1550+
15451551
return tagElm
15461552
},
15471553

0 commit comments

Comments
 (0)