-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group Blocks: Add margin support (top/bottom). #37344
Group Blocks: Add margin support (top/bottom). #37344
Conversation
@kjellr oops thanks for pointing this out. I must have missed that as I was only looking at open PRs before I added this. Still feel strongly that this is needed and added a comment over there. |
I would like us to revisit this PR. This PR fixes the Group component of #38629, address a workaround for #37811, and is consistent with how Columns blocks currently handle margin (only top/bottom). Furthermore, theme developers can opt out in theme.json. I understand the greater concern about margin not being that intuitive in a Either way, I think a line needs to be drawn in the sand before 6.0. Either we add margin to "container" blocks like Group and Cover along with Columns, or we don't ever add margin control and margin should be removed from Columns and other blocks that support it. If the later is the case, then we need to explore a more robust way to address the concerns of the community. Currently it is way too easy for users to say "X block supports margin, why doesn't Y block support margin?" Obviously I am in the camp of margin control 😉, but I recommend we have a good conversation here about the merits of both approaches and chart a path forward. Sorry for the pings, but elevating this to those who have participated in similar discussions in the past. |
+1 to margin control on group blocks. You can't do |
I'm struggling to come up with any reasons the group block should not support top/bottom margins. The blockGap argument seems pretty hollow, since other blocks still have margin controls. |
👋 I know there are countless development-centric reasons to have margin support here (and globally, frankly) in the editor. So I'd like to clarify/remind folks that the reason margin has been left out here is that the feature is likely to be confusing to users. As noted in other threads:
The blocker here isn't a technical one, it's a design one. We just haven't figured out those issues, and it wasn't a design priority for the 5.9 release. |
Thanks for including the additional reasoning behind the decision @kjellr. While I respect the reasoning, I would like to push back lightly on a few points.
This PR is only advocating for top/bottom margin, not left/right. This change is consistent to the margin implementation currently on Columns blocks.
Spacer blocks are very useful, but they do not address the situation when you need to set Finally, given that margin support can very easily be disabled in theme.json, developers who are concerned about their users being confused about both padding and margin, can just disable it in their themes. |
Kjell's comment perfectly echoes my sentiments on the matter, the blocker is a design one. Notably for block theme templates in the site editor, it's likely that the increased in-canvas visibility the spacer provides will make spacing customization more intuitive for most people. Here in the post 5.9 phase, we could start exploring paths forward, the key being to seek out in-canvas solutions. So long as those explorations are not hindered, in the mean time, we could open up the margin support for a few blocks as a non-default addition to the tools panel. What do you think? |
There's a few levels to this:
|
I bet many of the cases for block gap issues could be handled directly by handling some exceptions too. This would also be a good example of that case: #38675 |
Yeah, even exposing a |
💯 If margin is implemented, I believe it should always be "hidden" in the tools panel. That hopefully will decrease the confusion for novice users while also enabling this feature for others. I also completely agree that continued exploration should not be hindered.
Thank you for being open to this @mtias! 🙏
💯 Agree. This is just a side benefit of margin support while a more robust solution is found.
The easiest example is probably two full-width Cover blocks, one after another. Perhaps both have background color and you want them to butt up against one another. This is not currently possible since blockGap will separate them. Another example is a Header template part with a colored background and you want that to butt up against a full-width Featured Image block. Again they will be separated by the global blockGap value. Thank you all for this thoughtful discussion. 🙌 |
Adding a similar example to @ndiego's above. I also came across this limitation when trying to stack colored layout blocks (Group, Column) on top of each other while creating a theme. When declaring a "blockGap" value in Video.MP4.480x346.mp4
This is probably an overly-simplistic view, however I’m wondering if we could separate the “blockGap” we use at the block level, for example, in the Social Icons block, from the layout implemention. That way we'd have a control under the Layout panel in the sidebar that is explicitly bound to the layout's usage of So for example, into layout via "__experimentalLayout": {
"allowSwitching": false,
"allowInheriting": false,
"default": {
"type": "flex"
},
"blockSpacing": "24px"
} I'm not sure, but it just might help to avoid situations such as these: #35411 where the layout's |
Does anyone have additional concerns, or can this be approved? Happy to provide more examples/explanation if needed. |
It's late for me and I'm not able to review and approve this PR today, though I can take a look tomorrow. Otherwise for any other reviewers, some quick high level thoughts: it seems fine to add margin to the group block if it's a tools panel addition to the dimensions panel, which is off by default. If that works as intended, 👍 👍 for moving forward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving tentative approval to this one based on the commentary and the fact that it tests well for me:
Even shown in that GIF the collapsing of margins can make it confusing why a low margin has no effect, but the cause of this has been discussed ad nauseum, and is fine so long as it remains a non-default control and we continue to explore better and additional controls!
(For those explorations, and simply due to margin collapsing, it seems to suggest we need to highlight not just the margin of the selected block, but indeed the margin of adjacent blocks too)
Thanks for your patience (and PR)!
Thanks @jasmussen! 🙏 I completely agree with you that margin is confusing in the Editor, especially if you don't know that In the meantime though, enabling margin functionality on Group blocks opens the doors to so many interesting patterns and designs without the need for custom CSS. It's so exciting. Thank you to everyone for your input, understanding, and flexibility on this topic! I'll give it until Monday for others to share any last-minute feedback, for or against, and then merge. |
I've given this PR a run-through as well, looks good to me. 👍 |
Hi, @ndiego I just noticed that Static Analysis is failing for merge commit. You probably will need to generate updated docs for Groups block. |
@Mamaduka on it! |
Margin support for Group blocks was added in #37344.
@ndiego thanks for persisting with this :) |
@mtias haha perhaps too persistent. Thank you for being open to this enhancement. 🙏 It appears to be well received: https://twitter.com/nickmdiego/status/1495791576194428931 |
Hi @ndiego thanks for all of your work on this; could you update your initial PR to read :) |
Description
This PR simply adds margin support to Group blocks, specifically the Editor UI. Margin is actually already supported, just not the UI. With this PR, theme developers can opt-in to margin support either by using the
settings.spacing.appearanceTools.true
flag, or at the block level withsettings.blocks.core/group.spacing.margin.true
in theme.json.Note that this PR restricts margin to top/bottom, which is in keeping with the approach currently applied to Columns blocks.
There are countless reasons why allowing margin control on Group block is extremely useful when designing in the Editor. Here is one such example: #36797 (comment).
As mentioned in #37300, which concerns adding margin support to Paragraph blocks, theme developers (myself included) are resorting to "magic classes" to zero out, or modify, margins on blocks. Allowing themes to opt-in to Group margin support will provide greater flexibility and decrease the reliance on custom CSS/classes in the theme's stylesheet.
How has this been tested?
settings.spacing.appearanceTools.true
is set in theme.jsonsettings.blocks.core/group.spacing.margin.true
.Screenshots
Types of changes
New Feature
Checklist:
*.native.js
files for terms that need renaming or removal).