-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Root padding is doubled on child blocks #43095
Comments
I can confirm. See screenshot. The key appears to be the To replicate, implement Rich's theme.json settings above and use the following block markup:
|
@tellthemachines and @andrewserong pinging you both on this. 🙏 |
Thanks for the report! I can reproduce this in Empty theme by adding I'll have a think about how best to fix this - removing the padding from |
Hmm, seems like the extra padding we're seeing in those examples is actually coming from a rule that targets blocks with background-color, and not from the root padding styles themselves: What's happening is that the current TT2 custom logic for root padding overrides that background-color padding with a more specific rule: This is because TT2 logic works by adding a negative margin to In core, instead of adding padding to I'm afraid there's no straightforward fix for this 😅 but it might be a good time to re-evaluate that background-color rule, because it also interferes with nested In the meantime, if you're looking to adopt the core root padding system in TT2, maybe popping a temporary override in the theme stylesheet is the best way to unblock this. I'm thinking something like |
@bgardner and I did some more testing on this front, looking at Twenty Twenty Three. I don't think this doubled-up padding is due to the background color, but rather the targeting of padding on contents within What's happeningThe SuggestionWe should get more eyes on this, but if we remove this rule entirely, the double padding is no longer applied to blocks within fullwidth, constrained blocks. This ensures that all blocks have the proper left/right padding from the In the screenshot below I have two shots on the left of the doubled padding displaying, with and without background colors applied to the group block. On the right is the result of commenting out this rule. |
In some testing, I think modifying the rule to the following should work. The issue with removing it completely is that it impacts blocks with
|
@andrewserong sorry for the ping, but this is the last piece of the "root site padding" puzzle. |
What does it cause? |
Thanks for the report! |
Padding on inner blocks is not applied. Blocks with
This almost works, but not quite. The padding on blocks inside of the child block with Changing the CSS to the following seems to solve the issue, but I don't love it.
|
To help illustrate what is going on, here's a link: https://bg.design/powder/test/ Both instances have groups with content that should be aligned with the content in the header/footer, but the double padding is bumping it in another 30 px. |
These rules were arrived at after a lot of back-and-forth both on #42085 and #35607. For any fix we try, we'll need to make sure that we're not breaking any expected behaviour. I think it would help to have our expectations clearly documented (which I now wish I'd done while I was wrangling the PR 😅 ) so going to address that now along with trying out a fix. |
100% agree, but in its current state this doesn’t work. I’d expect not to have 2x padding applied to nested fullwidth blocks. That’s how Twenty Twenty Two works, and how I’d expect any theme to work. Removing that CSS glob and opting into padding with TT2 would be a regression. |
Sure, I'm looking at a fix for that now. |
🙏🚀 |
This would be lovely! |
Description
A lot of effort has gone into consolidating and simplifying block theme support for making blocks fullwidth, while also supporting root padding, particularly in #42085.
I've been testing this out with TT2 and it looks like padding is inaccurately applied to child blocks, doubling up the padding within.
Do we need the following generated styles — or should we be zeroing out padding if
.has-global-padding
>.has-global-padding
occurs?I think we're really close on getting a root padding/fullwidth that "just works" 🤞
Step-by-step reproduction instructions
"settings.useRootPaddingAwareAlignments": true
to the theme.jsonScreenshots, screen recording, code snippet
.has-global-padding
is being applied to subsequent fullwidth blocks, which doubles the amount of left/right padding. This doubled padding is only perceptible on mobile as the viewport is small enough to see the effect:Environment info
WordPress 6.0.1
Twenty Twenty Two (modified from above)
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: