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

Some block patterns do not show in the inserter #32139

Closed
carolinan opened this issue May 24, 2021 · 4 comments · Fixed by #32376
Closed

Some block patterns do not show in the inserter #32139

carolinan opened this issue May 24, 2021 · 4 comments · Fixed by #32376
Assignees
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

When testing the block patterns that are planned for Twenty Fourteen,
I learnt that the patterns show correctly in 10.6.2 but not in 10.7 RC1.
With 10.7 RC1, only two of the patterns show (summary and contact).

I was able to reproduce this in my own themes. It seems to be related to spacing inside the content.

The following does not work, the pattern is not selectable:

register_block_pattern(
		'twentyfourteen/list',
		array(
			'title'         => esc_html__( 'List', 'twentyfourteen' ),
			'categories'    => array( 'twentyfourteen' ),
			'viewportWidth' => 1000,
			'content'       => '<!-- wp:columns -->
								<div class="wp-block-columns"><!-- wp:column {"width":"40%"} -->
								<div class="wp-block-column" style="flex-basis:40%">
								... truncated

The following does work:

register_block_pattern(
		'twentyfourteen/list',
		array(
			'title'         => esc_html__( 'List', 'twentyfourteen' ),
			'categories'    => array( 'twentyfourteen' ),
			'viewportWidth' => 1000,
			'content'       => '<!-- wp:columns --><div class="wp-block-columns"><!-- wp:column {"width":"40%"} --><div class="wp-block-column" style="flex-basis:40%"><!-- wp:heading {"style":{"typography":{"fontSize":45}}} --><h2 style="font-size:45px">' . esc_html__( '2001', 'twentyfourteen' ) . '</h2><!-- /wp:heading --></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"><!-- wp:paragraph --><p><em>' . esc_html__( 'My first year of traveling. I visited China, Thailand, Japan, and India.', 'twentyfourteen' ) . '</em></p><!-- /wp:paragraph --></div><!-- /wp:column --></div>
... truncated

Step-by-step reproduction instructions

  1. Download the patch for the patterns in Twenty Fourteen, or copy the pattern code into your current theme.
  2. In the editor, open the inserter, select patterns, select the Twenty Fourteen category, and see that only two patterns show.

Expected behaviour

All registered patterns should show

Actual behaviour

Only two of the patterns show.

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: 10.7.0 RC1
  • Are all plugins except Gutenberg deactivated? yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Twenty Fourteen with above pull request. Armando.

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Chrome Version 90.0.4430.212
@carolinan carolinan added the [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced label May 24, 2021
@justintadlock
Copy link
Contributor

Thank you for at least figuring out what wasn't working with this. I've been digging everywhere and testing (almost) everything to figure out why none of my 30+ patterns were working.

@justintadlock
Copy link
Contributor

I ran all my patterns through this for a quick fix:

'content' => str_replace( [ "\n", "\r", "\t" ], '', $pattern_content )

@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label May 28, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 1, 2021
@kopepasah
Copy link
Member

@youknowriad I am not certain this issue is resolved, as when trying to register the following pattern on WP 5.9.1, it does not register:

register_block_pattern(
	'wp-core-test/test-pattern-with-columns',
	[
		'title'   => 'Test Pattern',
		'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:columns --><div class="wp-block-columns"><!-- wp:column --><div class="wp-block-column"></div><!-- /wp:column --><!-- wp:column --><div class="wp-block-column"></div><!-- /wp:column --></div><!-- /wp:columns --></div><!-- /wp:group -->',
	]
);

However, the following pattern does register:

register_block_pattern(
	'wp-core-test/test-pattern-with-columns',
	[
		'title'   => 'Test Pattern',
		'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:columns --><div class="wp-block-columns"></div><!-- /wp:columns --></div><!-- /wp:group -->',
	]
);

I discovered this issue when trying to make a two column pattern (with headings, paragraphs, images, etc), and only when we remove the columns does the pattern register.

@kopepasah kopepasah reopened this Mar 11, 2022
@kopepasah
Copy link
Member

Never mind, the issue was that the core/column block was on our allowed list. However, I will note that we are still able to use the core/column block when it is not allowed and the core/columns block is allowed. This seems like expected behavior, as we wouldn't want to allow columns without a column. Probably worth investigating, as while we can use it in the editor, we cannot use it in patterns.

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 [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants