Embed Block: Fix collapse in Stack blocks#75596
Embed Block: Fix collapse in Stack blocks#75596Mustafabharmal wants to merge 3 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
| } | ||
|
|
||
| // Fix for Stack blocks (vertical orientation) - embeds need explicit width to maintain aspect ratio. | ||
| .wp-block-group.is-layout-flex.is-vertical .wp-block-embed { |
There was a problem hiding this comment.
Should this be
| .wp-block-group.is-layout-flex.is-vertical .wp-block-embed { | |
| .wp-block-group.is-layout-flex.is-vertical > .wp-block-embed { |
To avoid breaking nested containers?
There was a problem hiding this comment.
Based on current discussion, I think the immediate descendant selector should be removed to target any depth of the embed.
Is .wp-block-group necessary in that selector?
There was a problem hiding this comment.
Good call! I've removed both the > and .wp-block-group from the selectors in commit 6355a63. The updated rules are now:
.is-layout-flex .wp-block-embed {
flex: 1 1 0%;
min-width: 0;
}
.is-layout-flex.is-vertical .wp-block-embed {
width: 100%;
}|
I noticed something, if I have an embed within a group within a stack, the embed is collapsed because the group width adapts to the content. I'm honestly not sure what we should be doing here, I think the width of the group adapting to the content (when within a stack) is kind of expected, so I tend to think that even if the embed is collapsed, things are working as expected here. What do you think @mrwweb @mtias ? |
|
@youknowriad That matches my experiences as well.
For someone with a deep knowledge of CSS, that is indeed the expected behavior, but I can't imagine that is actually the expected behavior for any editor, even those who know why it happens. Watching a block disappear in front of you in the editor feels like an unacceptable experience. I know that in theory an embed might not be 100% width, but do people have examples of this? I can't actually think of any examples from my real work where that wouldn't be true. One point in favor of |
|
The problem with that style @mrwweb is that if you have a row within a stack which is totally valid designs, you might have all the embeds (YouTube videos for instance), on separate rows (due to with 100%) while you added a row explicitly to render them in a row. So I'm actually wondering if a "min-width" could be a solution in the case of collapsed embeds here. |
What?
Closes #75592
Fixes embed blocks collapsing to 0x0 in Stack blocks (vertical flex layouts).
Why?
Follow-up to #73109, which fixed the issue for Row blocks but not Stack blocks.
Embeds with responsive aspect ratios collapse when placed inside Stack blocks (Group blocks with vertical flex orientation). While the previous fix added flex properties that work for horizontal layouts (Row blocks), vertical flex containers require an explicit width to prevent collapse while maintaining the aspect ratio.
How?
Adds a CSS rule targeting embeds inside vertical flex layouts:
Testing Instructions
Screenshots or screencast
Before: Embeds collapse in Stack blocks
After: Embeds display correctly maintaining their aspect ratio