Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill quick inserter results with available variations if limit is set and items are less. #24481

Merged
merged 5 commits into from
Aug 12, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/inserter/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const getItemFromVariation = ( item ) => ( variation ) => ( {
* @return {Array} Normalized inserter items.
*/
export function includeVariationsInInserterItems( items, limit = Infinity ) {
if ( items.length >= limit ) {
// No need to iterate for variations
return items.slice( 0, limit );
}

ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
// Exclude any block type item that is to be replaced by a default
// variation.
const filteredItems = items.filter(
Expand Down