Skip to content

Commit

Permalink
fixes #868 - when allowing duplicates, duplicates are not matched wit…
Browse files Browse the repository at this point in the history
…h the filtered whitelist
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Aug 20, 2021
1 parent aa162f5 commit 8016cf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dist/tagify.min.js
Expand Up @@ -2646,8 +2646,9 @@

var filteredList = this.dropdown.filterListItems.call(this, item[tagTextProp], {
exact: true
}) // also filter out items which have already been matches in previous iterations
.filter(filteredItem => !whitelistMatchesValues.includes(filteredItem.value)); // get the best match out of list of possible matches.
});
if (!this.settings.duplicates) // also filter out items which have already been matches in previous iterations
filteredList = filteredList.filter(filteredItem => !whitelistMatchesValues.includes(filteredItem.value)); // get the best match out of list of possible matches.
// if there was a single item in the filtered list, use that one

var matchObj = filteredList.length > 1 ? this.getWhitelistItem(item[tagTextProp], tagTextProp, filteredList) : filteredList[0];
Expand Down
5 changes: 4 additions & 1 deletion src/tagify.js
Expand Up @@ -977,8 +977,11 @@ Tagify.prototype = {
// if suggestions are shown, they are already filtered, so it's easier to use them,
// because the whitelist might also include items which have already been added
var filteredList = this.dropdown.filterListItems.call(this, item[tagTextProp], { exact:true })


if( !this.settings.duplicates )
// also filter out items which have already been matches in previous iterations
.filter(filteredItem => !whitelistMatchesValues.includes(filteredItem.value))
filteredList = filteredList.filter(filteredItem => !whitelistMatchesValues.includes(filteredItem.value))

// get the best match out of list of possible matches.
// if there was a single item in the filtered list, use that one
Expand Down

0 comments on commit 8016cf8

Please sign in to comment.