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

When Gutenberg is active, block patterns listed in theme.json does not appear #41959

Closed
carolinan opened this issue Jun 26, 2022 · 4 comments
Closed
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced

Comments

@carolinan
Copy link
Contributor

Description

In theme.json, I have added the following patterns from the pattern directory:
"patterns": [ "site-footer-with-logo-contact-info-social-links-and-copyright", "heading-with-two-font-sizes-and-separators" ]
The version of the theme.json file is 2.
The patterns are in the categories text, columns and headers respectively.

Without Gutenberg active, the patterns show up in the pattern inserter or pattern explorer for these categories.
When I activate Gutenberg, the patterns are not available.

Step-by-step reproduction instructions

  1. Install WordPress 6.0
  2. Deactivate Gutenberg, if it is active.
  3. Add the array of patterns to theme.json of Twenty Twenty-Two or for example Empty theme.
  4. In the site editor and block editor respectively, open the block inserter and select the patterns tab. Look under the mentioned categories and confirm that the two patterns are listed. You can also try using the search and search for "footer".
  5. Activate Gutenberg and try to find the two patterns. Confirm that they are not listed. There are lots of other patterns listed, but not the patterns you added to theme.json.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.0

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

@Mamaduka Mamaduka added the [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced label Jun 27, 2022
@petitphp
Copy link
Contributor

petitphp commented Jul 6, 2022

I managed to reproduce the issue following the steps provided.

After looking at this, it appear to be a known issue where the WP_REST_Pattern_Directory_Controller wasn't supporting array arguments.

The patterns listed in theme.json were send has an array to the WP_REST_Pattern_Directory_Controller with the slug parameter. Internally the value from the parameter was drop when building the request to the WP.org pattern directory resulting in the listed patterns missing in the editor.

This has been fixed in core in WP 6.0. The change has been backported to gutenberg in #40900 and is available in trunk but not yet released in the Gutenberg plugin distributed in the plugin directory (as far as I can see).

@carolinan
Copy link
Contributor Author

It was released with Gutenberg 13.5.
The issue remains in Gutenberg trunk and Gutenberg 13.6.0.

@petitphp
Copy link
Contributor

petitphp commented Jul 7, 2022

The PR was merged 7 days ago. I checked the content of lib/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller.php file in tags 13.5.0/13.5.1/13.5.2/13.6.0 and it hasn't change since february 10.

The PR might have been schedule to be included in 13.5 but wasn't merge in time ?

@carolinan
Copy link
Contributor Author

Retested with 14.0.2, and the patterns are listed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced
Projects
None yet
Development

No branches or pull requests

3 participants