Compound block and layout type classname incorrect for custom blocks #53295
Labels
[Feature] Blocks
Overall functionality of blocks
[Feature] Layout
Layout block support, its UI controls, and style output.
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
As per Layout updates in the editor for WordPress 6.3:
However, this does not work for third-party blocks since the vendor prefix of the block gets cut off in the class name generated in markup, but the CSS generated from the style engine has the prefix.
Given the block detailed in the code snippet further down, you'll get markup like this in the block editor:
With the associative CSS (where
settings.styles.blocks.foo/bar.spacing.blockGap
has been set tovar(--wp--preset--spacing--12)
intheme.json
):Notice how the combined CSS classes like
wp-block-foo-bar-is-layout-flow
havewp-block-foo-bar-
but the class name on the HTML block itself iswp-block-bar-
.This difference seems to be due to the
packages/block-editor/src/hooks/layout.js
only looking at the second part of the block name after the slash (/
):gutenberg/packages/block-editor/src/hooks/layout.js
Lines 69 to 76 in 00a1b6e
when building the class name for HTML.
This behavior is mirrored for server side layout supports PHP code, from the
6.3
branch:Again, only looking at the second part of the block name after the slash (
/
).The CSS I believe comes from
WP_Theme_JSON::get_layout_styles()
and we can see the difference with how the CSS is constructed:Step-by-step reproduction instructions
<div>
, both in the editor or in the live webpage.Screenshots, screen recording, code snippet
Example block:
block.json
:index.js
:index.js
(no build step neccessary):Environment info
WordPress 6.3-RC3-56344
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
The text was updated successfully, but these errors were encountered: