Skip to content

Commit

Permalink
Code change per review
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 4, 2020
1 parent c164f19 commit 15b61e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions packages/block-editor/src/components/inserter/search-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ export const searchItems = ( items, searchTerm, config = {} ) => {
const collection = getCollection( item );
const variations = getVariations( item );

const terms = [ title, keywords, category, collection, variations ]
.flat()
.join( ' ' );
const terms = [
title,
...keywords,
category,
collection,
...variations,
].join( ' ' );

const unmatchedTerms = removeMatchingTerms(
normalizedSearchTerms,
Expand Down
18 changes: 9 additions & 9 deletions packages/block-editor/src/components/inserter/use-async-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import { createQueue } from '@wordpress/priority-queue';
*/
function getFirstItemsPresentInState( list, state ) {
const firstItems = [];
let index = 0;
let alreadyRendered = false;
do {
const item = list[ index ];
alreadyRendered = state.indexOf( item ) !== -1;
if ( alreadyRendered ) {
firstItems.push( item );

for ( let i = 0; i < list.length; i++ ) {
const item = list[ i ];
if ( ! state.includes( item ) ) {
break;
}
index++;
} while ( alreadyRendered || index === list.length );

firstItems.push( item );
}

return firstItems;
}

Expand Down

0 comments on commit 15b61e0

Please sign in to comment.