From c5578303605ed94824a71b92b30adf2877a62ca4 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Thu, 9 Jun 2022 15:37:48 +0300 Subject: [PATCH] Lodash: Refactor away from _.differenceWith() in the inserter --- .../src/components/inserter/search-items.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/inserter/search-items.js b/packages/block-editor/src/components/inserter/search-items.js index 292d2bf95743b..d846f01eac955 100644 --- a/packages/block-editor/src/components/inserter/search-items.js +++ b/packages/block-editor/src/components/inserter/search-items.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { deburr, differenceWith, find, words } from 'lodash'; +import { deburr, find, words } from 'lodash'; // Default search helpers. const defaultGetName = ( item ) => item.name || ''; @@ -47,11 +47,11 @@ export const getNormalizedSearchTerms = ( input = '' ) => { }; const removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => { - return differenceWith( - unmatchedTerms, - getNormalizedSearchTerms( unprocessedTerms ), - ( unmatchedTerm, unprocessedTerm ) => - unprocessedTerm.includes( unmatchedTerm ) + return unmatchedTerms.filter( + ( term ) => + ! getNormalizedSearchTerms( + unprocessedTerms + ).some( ( unprocessedTerm ) => unprocessedTerm.includes( term ) ) ); };