-
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
Root padding missing on nested alignfull blocks #44404
Comments
I confirm that the problem still exists. |
Thanks for your report @robrobsn!
This only happens with .alignfull blocks which also have the .has-global-padding classname, and I'm afraid it's a necessary side-effect of fixing #43095 so that no blocks get double the amount of padding.
That's because the rule is overriding It should also be noted that padding isn't applied to .alignfull blocks themselves, but only to some of their children. This is to avoid breaking Image, Video and other blocks that should always have full width content. In adding this feature to Core, the main concerns were providing some sensible defaults that can make theme building easier, and making the rules as generic as possible (avoiding targeting specific block types). This necessarily involves optimising for the most common cases, and given the amount of possible combinations of nested blocks with/without width constraints or alignments, it won't ever be possible to make it work in every single scenario. One workaround for the code example above is to remove the width constraint for the parent Group, and nest any contents you wish to constrain in another Group. This allows the any non-.alignfull children of the Groups with red background to receive padding. Padding on the Groups with background-color would also need adjusting, as these get a default value added from the block stylesheet (this is something that needs improvement, see #43110). You'd get something like this: For the .alignfull headings though, the best thing to do is add an equivalent amount of padding to the block itself (this is possible to do under "Dimensions" in the block sidebar). I'm going to go ahead and close this issue for now, but thanks again for looking into this! |
@tellthemachines Thank you for the detailed reply. The solution is disappointing, though.
Good point! To remove those paddings I suggest adding the following CSS code after the previous patch .has-global-padding > .alignfull:where(:not(.is-layout-constrained)) {
padding-left: 0;
padding-right: 0;
} In order to make .is-layout-flow.alignfull blocks work as well the following CSS rule should be removed, since the new .alignfull patch already manages the padding. .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]), p, h1, h2, h3, h4, h5, h6, ul, ol) {
padding-right: var(--wp--style--root--padding-right);
padding-left: var(--wp--style--root--padding-left);
} I added a .layout-is-flow group to the test content. Please see below for the updated test content. Updated test content```htmlregularwidefullregular in wideregular in fullwide in fullfull in fullwide in full in fullfull in full in fullregular in full layout-flow
I would not expect the user to manually have to add padding in order to make it work after specifically being set in the theme.json. Just the hassle of changing the root padding and having to update blocks manually to match it sounds
I agree a 100%. So, wouldn't it be more consistent/easier, code-wise and more user friendly if every element behaves the same, no exceptions by type. Meaning visually, if the user wants full width content, they chose alignfull, everything else has a visual root padding. Directly nested .alignfull container/layout blocks repeat having negative margin and padding and nested alignfull non-layout blocks have negative margin and zero padding to appear full width. This way there's no need to add rules for children and all their variations as you mentioned in your reply. |
I agree 100% with @robrobsn. The current solution is disappointing. |
Confirming this is still an issue? I believe I've stumbled across the same with |
Description
Follow-up for #43095
Might be relevant for #44336
When
useRootPaddingAwareAlignments
is set tottrue
in the theme.json, the double padding for nested.has-global
blocks has been fixed 🙌 but the root padding is now missing for nested.alignfull
blocks.The main issue is that the padding of
.alignfull
blocks inside.has-global-padding
blocks is missing because it is either not set or overwritten to zero.Adding the following rule after the existing ones fixes the issue for me:
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
TT3 before:
TT3 after patch:
If this fix turns out to be working as expected some of the old CSS rules can be removed or refactored.
Hope this helps! Root padding is definitely a tricky one.
Environment info
WordPress 6.0.2
Gutenberg 14.1.1
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: