Layout: Fix issue where layout classnames are injected for blocks without layout support#56187
Conversation
… blocks without layout support
|
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/block-supports/layout.php |
ramonjd
left a comment
There was a problem hiding this comment.
Before
<div class="wp-block-group is-nowrap is-layout-flex wp-container-core-group-layout-4 wp-block-group-is-layout-flex">
<p>Paragraph 1</p>
<p class="is-layout-flow wp-block-paragraph-is-layout-flow">Paragraph 2</p>
<p>Paragraph 3</p>
</div>After
<div class="wp-block-group is-nowrap is-layout-flex wp-container-core-group-layout-4 wp-block-group-is-layout-flex">
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
</div>🍺
apeatling
left a comment
There was a problem hiding this comment.
Can confirm exactly the same as Ramon above 👍
|
Thanks for the reviews! |
|
Thanks for fixing this! |
|
Backport open in WordPress/wordpress-develop#5900 |
|
✅ I updated this PR with the |
What?
This resolves an issue found while testing #56130 (review) — if a child of a Row block is explicitly set to
Fitthen layout classnames are erroneously injected for blocks that do not support layout (e.g. a paragraph block set to Fit as a child of the Row block).Why?
Layout classnames should not be output for blocks without layout support. They were being injected because we didn't have an early return condition for if a block has
selfStretchset, doesn't have layout support, but does not generate any styles.How?
Following the condition for outputting the outer wrapper classname for
selfStretchrules, perform an early return if the block does not support layout.Testing Instructions
trunkextra layout classnames are injected into the paragraph block.wp-container-content-xclassname and associated styles.Test markup:
Screenshots or screencast
Before
After