Skip to content

Block pattern: Pattern using another inner pattern doesn't show in Inserter modal #60379

@DamChtlv

Description

@DamChtlv

Description

Inserter modal doesn't show patterns that contains other patterns.

Step-by-step reproduction instructions

  1. Create a first pattern (will be our main pattern) and add it to your theme in /patterns/ (ex: test-pattern-1.php) :
<?php
/**
 * Title: Test pattern 1
 * Slug: abc/test-pattern-1
 * Categories: abc
 * Description: Test parent pattern issue
 * Keywords: test, parent, pattern
 * Block Types: core/post-content
 * Post Types: post, page
 * Inserter: true
 * Viewport Width: 1200
 * Source: theme
 */
?>
<!-- wp:pattern {"slug":"abc/test-pattern-2"} /-->
  1. Create a second pattern (will be our inner pattern) and add it to your theme in /patterns/ (ex: test-pattern-2.php) :
<?php
/**
 * Title: Test pattern 2
 * Slug: abc/test-pattern-2
 * Categories: abc
 * Description: Test pattern issue
 * Keywords: test, pattern
 * Block Types: core/paragraph
 * Viewport Width: 1200
 * Source: theme
 */
?>
<!-- wp:paragraph -->
<p>My text paragraph</p>
<!-- /wp:paragraph -->
  1. Go to Pages (or Posts), then click on "Add new"

  2. Inserter modal should popup and allow you to select the pattern "Test pattern 1" but nothing happens:
    image

  3. Edit test-pattern-1.php to replace wp:pattern code with direct block code of test-pattern-2.php and save:

<?php
/**
 * Title: Test pattern 1
 * Slug: abc/test-pattern-1
 * Categories: abc
 * Description: Test pattern issue
 * Keywords: test, pattern
 * Block Types: core/post-content
 * Post Types: post, page
 * Inserter: true
 * Viewport Width: 1200
 * Source: theme
 */
?>
<!-- wp:paragraph -->
<p>My text paragraph</p>
<!-- /wp:paragraph -->
  1. Go back to Pages (or Posts), then click on "Add new"
  2. Inserter modal shows up:
    image

Screenshots, screen recording, code snippet

image

image

Environment info

  • WordPress: 6.4.3 (LTS)
  • Gutenberg (same as WP 6.4.3)
  • Browser: Chrome
  • OS: Windows

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TestingNeeds further testing to be confirmed.[Feature] InserterThe main way to insert blocks using the + button in the editing interface[Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions