Making WordPress.org

Opened 2 years ago

Last modified 22 months ago

#6420 new defect (bug)

Missing support third-pary blocks in the theme patterns preview

Reported by: elmastudio's profile elmastudio Owned by:
Milestone: Priority: normal
Component: Theme Directory Keywords:
Cc:

Description

The new patterns preview does not support patterns build with third-party blocks.

In our Aino theme (https://wordpress.org/themes/aino/) we use our AinoBlocks blocks (https://wordpress.org/plugins/aino-blocks/). As a result, the preview looks very broken in our theme, see:

https://cldup.com/cxNK71CIC9.png

In comparison, the patterns in the editor patterns preview:

https://cldup.com/Hzev2U13SL.png

Can this be fixed, as I'm sure we are not the only ones using other than core blocks in their themes. And the broken preview does not look very inviting at the moment.

Change History (12)

#1 @dufresnesteven
2 years ago

Thanks for the ticket. I'll take a look :)

#2 follow-up: @kafleg
2 years ago

Thank you for creating your first meta ticket :) Warm welcome.

#3 @dd32
2 years ago

The solution here, IMHO, is to not do pattern previews of anything that requires a non-core/theme-provided block.

Themes can't require a plugin, and the previewer system can't support installing/activating arbitrary plugins per-theme.

Version 0, edited 2 years ago by dd32 (next)

#4 @dufresnesteven
2 years ago

I agree with @dd32.

If there were a previewer system that we could utilize or was on the roadmap, we could consider this fixable. However, it appears that even if the block editor starts to support missing blocks, it will probably only do so for blocks in the block directory.

Source: https://github.com/WordPress/gutenberg/issues/31706

As an action item, I think filtering out patterns that include non-core blocks is the best approach for now. I wouldn't want your theme to be impacted by "broken" looking patterns.

#5 @tellyworth
2 years ago

Given that themes shouldn't absolutely require a plugin, I'd suggest it's good practice to conditionally register only the patterns that will work given the blocks that exist on the site. Perhaps the theme should register patterns that use only core blocks, and the plugin should register any additional patterns that require blocks provided by the plugin.

#6 @elmastudio
2 years ago

Oh, ok, thanks so much for the clarifications. To be honest, I was not aware of the fact that patterns should only be shipped with the block plugin. Of course, I can also do it that way, no problem at all. I guess that was a misunderstanding from my side.

On another note, I asked multiple times already if patterns with third-party blocks that are available via the plugin directory can be submitted to the pattern directory. I would love to submit patterns there. So if this would be possible, then patterns could be made available for a theme, and we could preview them this way. This is just a thought, as the patterns' directory was mentioned.

#7 in reply to: ↑ 2 @elmastudio
2 years ago

I thought about this more and I know it might not fit into this ticket, but I want to add that initially we did have our patterns in the Block collection plugin. Then we changed that last year as we wanted to move towards single blocks, but then we would not have a chance to add patterns to the blocks.

My perfect solution would be imo that we could specify which blocks are needed in a theme via theme.json and they would then be automatically activated once the theme is installed.

Is this a valid idea or am I missing the point here?

#8 @elmastudio
2 years ago

In general, I feel like it would be helpful to have the possibility to hand out a set of blocks, patterns, and a block theme somehow as a package.

#9 @dufresnesteven
2 years ago

The Pattern Directory has the same restriction in that it currently only supports core blocks at the moment. As I mentioned above, it appears like Gutenberg will at some point support installing missing blocks for patterns, however, those blocks will need to be in the block directory as single blocks.

Links:
Block Directory Info: https://wordpress.org/support/article/block-directory/

This ticket was mentioned in Slack in #themereview by kafleg. View the logs.


2 years ago

#11 @dufresnesteven
22 months ago

Update: I have added a change that will only display patterns that are built with core blocks to ensure no broken patterns are displayed.

No progress on supporting third-party blocks.

#12 @dd32
22 months ago

In 12351:

wp-themes.com: Don't display patterns with third party blocks.

Unprops dd32 for missing this in [12349].

Props dufresnesteven.
See #6420.

Note: See TracTickets for help on using tickets.