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 | 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:
In comparison, the patterns in the editor patterns preview:
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)
#3
@
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.
#4
@
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
@
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
@
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
@
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
@
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
@
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/
Thanks for the ticket. I'll take a look :)