Skip to content

Commit

Permalink
fixes #850 - "keepInvalidTags" setting was keeping unwanted invalidit…
Browse files Browse the repository at this point in the history
…y-related properties on the tagData after each edit
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Jul 3, 2021
1 parent 06df9c6 commit 2f9b41c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 7 additions & 2 deletions dist/tagify.min.js
Expand Up @@ -1685,6 +1685,11 @@
if (_s.editTags.keepInvalid) return;
if (_s.keepInvalidTags) newTagData.__isValid = isValid;else // revert back if not specified to keep
newTagData = originalData;
} else if (_s.keepInvalidTags) {
// cleaup any previous leftovers if the tag was
delete newTagData.title;
delete newTagData["aria-invalid"];
delete newTagData.class;
} // tagElm.classList.toggle(_s.classNames.tagInvalid, true)


Expand Down Expand Up @@ -2165,9 +2170,9 @@

if (!isValid) {
this.removeTagsFromValue(tagElm);
this.update(); // update the original input with the current value
} //this.validateTag(tagData);
}

this.update(); //this.validateTag(tagData);

tagElm.classList.toggle(this.settings.classNames.tagNotAllowed, !isValid);
return tagData.__isValid;
Expand Down
7 changes: 7 additions & 0 deletions src/parts/events.js
Expand Up @@ -748,6 +748,13 @@ export default {
newTagData = originalData
}

else if( _s.keepInvalidTags ){
// cleaup any previous leftovers if the tag was
delete newTagData.title
delete newTagData["aria-invalid"]
delete newTagData.class
}

// tagElm.classList.toggle(_s.classNames.tagInvalid, true)

this.onEditTagDone(tagElm, newTagData)
Expand Down
4 changes: 3 additions & 1 deletion src/tagify.js
Expand Up @@ -476,9 +476,10 @@ Tagify.prototype = {

if( !isValid ){
this.removeTagsFromValue(tagElm)
this.update() // update the original input with the current value
}

this.update()

//this.validateTag(tagData);

tagElm.classList.toggle(this.settings.classNames.tagNotAllowed, !isValid)
Expand All @@ -499,6 +500,7 @@ Tagify.prototype = {
this.trigger("edit:beforeUpdate", eventData, {cloneData:false})

this.state.editing = false;

delete tagData.__originalData
delete tagData.__originalHTML

Expand Down

0 comments on commit 2f9b41c

Please sign in to comment.