From 14be95a5699730ee0474344464851ce0d3c0f71c Mon Sep 17 00:00:00 2001 From: Maggie Date: Tue, 23 Jul 2024 10:52:56 +0200 Subject: [PATCH] Limit pattern shuffling to theme and user patterns only (#62677) * add consition to remove core patterns from shuffle * reworded comment * Update packages/block-editor/src/components/block-toolbar/shuffle.js Co-authored-by: Ben Dwyer * linting --------- Co-authored-by: Ben Dwyer Co-authored-by: MaggieCabrera Co-authored-by: scruffian Co-authored-by: richtabor --- .../block-editor/src/components/block-toolbar/shuffle.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/components/block-toolbar/shuffle.js b/packages/block-editor/src/components/block-toolbar/shuffle.js index d86bfa82015699..e9101e76e65667 100644 --- a/packages/block-editor/src/components/block-toolbar/shuffle.js +++ b/packages/block-editor/src/components/block-toolbar/shuffle.js @@ -54,10 +54,16 @@ export default function Shuffle( { clientId, as = Container } ) { return EMPTY_ARRAY; } return patterns.filter( ( pattern ) => { + const isCorePattern = + pattern.source === 'core' || + ( pattern.source?.startsWith( 'pattern-directory' ) && + pattern.source !== 'pattern-directory/theme' ); return ( // Check if the pattern has only one top level block, // otherwise we may shuffle to pattern that will not allow to continue shuffling. pattern.blocks.length === 1 && + // We exclude the core patterns and pattern directory patterns that are not theme patterns. + ! isCorePattern && pattern.categories?.some( ( category ) => { return categories.includes( category ); } ) &&