Skip to content

Commit

Permalink
When the trim setting is true, tags added as objects should be tr…
Browse files Browse the repository at this point in the history
…immed as well
  • Loading branch information
yairEO committed May 6, 2024
1 parent b0f3e9c commit ccc142b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/tagify.js
Expand Up @@ -1053,10 +1053,20 @@ Tagify.prototype = {
// if is an Array of Strings, convert to an Array of Objects
else if( isArray ){
// flatten the 2D array
tagsItems = [].concat(...tagsItems.filter(n => n).map(item => item.value != undefined
? item // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
: mapStringToCollection(item)
))
tagsItems = tagsItems.reduce((acc, item) => {
if('value' in item) {
var itemCopy = extend({}, item)
itemCopy[tagTextProp] = this.trim(itemCopy[tagTextProp])

acc.push(itemCopy) // mapStringToCollection(item.value).map(newItem => ({...item,...newItem}))
}

else {
acc.push( mapStringToCollection(item) )
}

return acc
}, [])
}

// search if the tag exists in the whitelist as an Object (has props),
Expand Down

0 comments on commit ccc142b

Please sign in to comment.