Skip to content

Commit

Permalink
4.17.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Apr 12, 2023
1 parent ca3c92e commit 1edeb57
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
6 changes: 3 additions & 3 deletions dist/jQuery.tagify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react.tagify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions dist/tagify.esm.js
@@ -1,5 +1,5 @@
/**
* Tagify (v 4.17.7) - tags input component
* Tagify (v 4.17.8) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -936,7 +936,7 @@ var _dropdown = {

var value = elm.getAttribute('value'),
isNoMatch = value == 'noMatch',
tagData = this.suggestedListItems.find(item => (item.value || item) == value);
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value);

// The below event must be triggered, regardless of anything else which might go wrong
this.trigger('dropdown:select', {
Expand Down Expand Up @@ -1463,8 +1463,9 @@ var events = {
var focusedElm = document.activeElement,
isTag = isNodeTag.call(this, focusedElm),
isBelong = isTag && this.DOM.scope.contains(document.activeElement),
isReadyOnlyTag = isBelong && focusedElm.hasAttribute('readonly'),
nextTag;
if (!isBelong) return;
if (!isBelong || isReadyOnlyTag) return;
nextTag = focusedElm.nextElementSibling;
switch (e.key) {
// remove tag if has focus
Expand Down Expand Up @@ -1875,7 +1876,8 @@ var events = {
tagElm = e.target.closest('.' + _s.classNames.tag),
timeDiffFocus = +new Date() - this.state.hasFocus;
if (e.target == this.DOM.scope) {
if (!this.state.hasFocus) this.DOM.input.focus();
// if( !this.state.hasFocus )
this.DOM.input.focus();
return;
} else if (e.target.classList.contains(_s.classNames.tagX)) {
this.removeTags(e.target.parentNode);
Expand Down Expand Up @@ -2437,8 +2439,8 @@ Tagify.prototype = {
var lastChild,
_s = this.settings;

// temporarily block firign the "change" event on the original input unil
// this method finish removing current value and adding the new one
// temporarily block firing the "change" event on the original input until
// this method finish removing current value and adding a new one
this.state.blockChangeEvent = true;
if (value === undefined) {
const persistedOriginalValue = this.getPersistedData('value');
Expand All @@ -2463,7 +2465,6 @@ Tagify.prototype = {
}
} else this.postUpdate();
this.state.lastOriginalValueReported = _s.mixMode.integrated ? '' : this.DOM.originalInput.value;
this.state.blockChangeEvent = false;
},
cloneEvent(e) {
var clonedEvent = {};
Expand Down Expand Up @@ -3023,7 +3024,7 @@ Tagify.prototype = {
// if is an Array of Strings, convert to an Array of Objects
else if (isArray) {
// flatten the 2D array
tagsItems = [].concat(...tagsItems.map(item => item.value ? item // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
tagsItems = [].concat(...tagsItems.map(item => item.value != undefined ? item // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
: mapStringToCollection(item)));
}

Expand Down Expand Up @@ -3562,6 +3563,7 @@ Tagify.prototype = {
this.update(opts);
},
postUpdate() {
this.state.blockChangeEvent = false;
var _s = this.settings,
classNames = _s.classNames,
hasValue = _s.mode == 'mix' ? _s.mixMode.integrated ? this.DOM.input.textContent : this.DOM.originalInput.value.trim() : this.value.length + this.input.raw.call(this).length;
Expand Down Expand Up @@ -3593,8 +3595,8 @@ Tagify.prototype = {
function reallyUpdate() {
var inputValue = this.getInputValue();
this.setOriginalInputValue(inputValue);
this.postUpdate();
if ((!this.settings.onChangeAfterBlur || !(args || {}).withoutChangeEvent) && !this.state.blockChangeEvent) this.triggerChangeEvent();
this.postUpdate();
}
},
getInputValue() {
Expand Down
20 changes: 11 additions & 9 deletions dist/tagify.js
@@ -1,5 +1,5 @@
/**
* Tagify (v 4.17.7) - tags input component
* Tagify (v 4.17.8) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -942,7 +942,7 @@

var value = elm.getAttribute('value'),
isNoMatch = value == 'noMatch',
tagData = this.suggestedListItems.find(item => (item.value || item) == value);
tagData = this.suggestedListItems.find(item => (item.value ?? item) == value);

// The below event must be triggered, regardless of anything else which might go wrong
this.trigger('dropdown:select', {
Expand Down Expand Up @@ -1469,8 +1469,9 @@
var focusedElm = document.activeElement,
isTag = isNodeTag.call(this, focusedElm),
isBelong = isTag && this.DOM.scope.contains(document.activeElement),
isReadyOnlyTag = isBelong && focusedElm.hasAttribute('readonly'),
nextTag;
if (!isBelong) return;
if (!isBelong || isReadyOnlyTag) return;
nextTag = focusedElm.nextElementSibling;
switch (e.key) {
// remove tag if has focus
Expand Down Expand Up @@ -1881,7 +1882,8 @@
tagElm = e.target.closest('.' + _s.classNames.tag),
timeDiffFocus = +new Date() - this.state.hasFocus;
if (e.target == this.DOM.scope) {
if (!this.state.hasFocus) this.DOM.input.focus();
// if( !this.state.hasFocus )
this.DOM.input.focus();
return;
} else if (e.target.classList.contains(_s.classNames.tagX)) {
this.removeTags(e.target.parentNode);
Expand Down Expand Up @@ -2443,8 +2445,8 @@
var lastChild,
_s = this.settings;

// temporarily block firign the "change" event on the original input unil
// this method finish removing current value and adding the new one
// temporarily block firing the "change" event on the original input until
// this method finish removing current value and adding a new one
this.state.blockChangeEvent = true;
if (value === undefined) {
const persistedOriginalValue = this.getPersistedData('value');
Expand All @@ -2469,7 +2471,6 @@
}
} else this.postUpdate();
this.state.lastOriginalValueReported = _s.mixMode.integrated ? '' : this.DOM.originalInput.value;
this.state.blockChangeEvent = false;
},
cloneEvent(e) {
var clonedEvent = {};
Expand Down Expand Up @@ -3029,7 +3030,7 @@
// if is an Array of Strings, convert to an Array of Objects
else if (isArray) {
// flatten the 2D array
tagsItems = [].concat(...tagsItems.map(item => item.value ? item // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
tagsItems = [].concat(...tagsItems.map(item => item.value != undefined ? item // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
: mapStringToCollection(item)));
}

Expand Down Expand Up @@ -3568,6 +3569,7 @@
this.update(opts);
},
postUpdate() {
this.state.blockChangeEvent = false;
var _s = this.settings,
classNames = _s.classNames,
hasValue = _s.mode == 'mix' ? _s.mixMode.integrated ? this.DOM.input.textContent : this.DOM.originalInput.value.trim() : this.value.length + this.input.raw.call(this).length;
Expand Down Expand Up @@ -3599,8 +3601,8 @@
function reallyUpdate() {
var inputValue = this.getInputValue();
this.setOriginalInputValue(inputValue);
this.postUpdate();
if ((!this.settings.onChangeAfterBlur || !(args || {}).withoutChangeEvent) && !this.state.blockChangeEvent) this.triggerChangeEvent();
this.postUpdate();
}
},
getInputValue() {
Expand Down
4 changes: 2 additions & 2 deletions dist/tagify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tagify.polyfills.min.js
@@ -1,5 +1,5 @@
/**
* Tagify (v 4.17.7) - tags input component
* Tagify (v 4.17.8) - tags input component
* By undefined
* https://github.com/yairEO/tagify
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@yaireo/tagify",
"version": "4.17.7",
"version": "4.17.8",
"homepage": "https://github.com/yairEO/tagify",
"description": "lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]",
"keywords": [
Expand Down

0 comments on commit 1edeb57

Please sign in to comment.