Repository navigation
Conversation
…ck appender Ensured consistent margin application for blocks with dynamic block appender
…ck appender Ensured consistent margin application for blocks with dynamic block appender
Revert the unwanted changes
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for picking this up @Sourav61 👍
I've only had a chance to quickly test this with TT5, a 48px global style margin on Cover blocks. The margin still shows when the group is selected, in both the block and site editors.
The block appender only shows in the editor so the rule in the PHP layout config won't ever match anything.
Also, the appender margin issue impacts flow layouts which have the same :last-child rule.
I think all we'll need here is to define the rule within the JS side of layouts.
Something like:
selector: ' > :has(+ :where(.block-list-appender):last-child)',The :where() should keep the same specificity as > :last-child. A quick local test seemed to fix both editors.
| This PR | JS engine rule | |
|---|---|---|
| Where the rule lands | Front end only | Editor only |
| Layouts | Constrained | Flow and constrained |
| Specificity | 0-3-0 | 0-2-0, same as > :last-child |
| Editor margin when selected | Still 48px | 0, matches front end |
I can throw up an alternative PR if this PR is too stale.
|
Looks like I was wrong in my earlier review. A PHP stylesheet does reach the editor for hybrid themes, i.e. classic themes that have a I think the final solution should be the rule in the JS engine and a PHP rule that goes into the editor styles only so the unnecessary style doesn't reach the frontend. |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
Ensured consistent margin application for blocks when block list appender appears
What?
Closes #61846
Fixes an issue where the .block-list-appender dynamically modifies the block structure, causing inconsistent margin application for blocks inside .is-layout-constrained containers. This ensures that margins are correctly applied even when the block appender is added or removed dynamically.
Why?
Previously, when a block (e.g., Cover block) was inside a Group block with .is-layout-constrained, the following CSS rules were applied:
However, when selecting the Group block in the editor, the .block-list-appender gets appended to the group, making it the new :last-child, which removes the intended margin adjustments from the actual content block, causing a layout shift.
How?
Testing Instructions