From 8016cf80cab59828fee9ac3b624ee49a60575088 Mon Sep 17 00:00:00 2001 From: Yair Even Or Date: Fri, 20 Aug 2021 11:50:29 +0300 Subject: [PATCH] fixes #868 - when allowing duplicates, duplicates are not matched with the filtered whitelist --- dist/tagify.min.js | 5 +++-- src/tagify.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/tagify.min.js b/dist/tagify.min.js index 0d0d507d..00d11f5d 100644 --- a/dist/tagify.min.js +++ b/dist/tagify.min.js @@ -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]; diff --git a/src/tagify.js b/src/tagify.js index 79ee1169..5e39a99b 100644 --- a/src/tagify.js +++ b/src/tagify.js @@ -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