Skip to content

Commit

Permalink
Limit pattern shuffling to theme and user patterns only (WordPress#62677
Browse files Browse the repository at this point in the history
)

* 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 <[email protected]>

* linting

---------

Co-authored-by: Ben Dwyer <[email protected]>
Co-authored-by: MaggieCabrera <[email protected]>
Co-authored-by: scruffian <[email protected]>
Co-authored-by: richtabor <[email protected]>
  • Loading branch information
5 people authored Jul 23, 2024
1 parent 1502969 commit 14be95a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/block-editor/src/components/block-toolbar/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
} ) &&
Expand Down

0 comments on commit 14be95a

Please sign in to comment.