-
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
6.5: Maximum width of wide blocks inside group set to Alignment: Full is overwritten in classic themes #60413
Comments
Adding this to the 6.5.x board to triage. @tellthemachines @andrewserong is this something you can look into with the work you all have done around layout? @carolinan too for your thoughts as you're a wiz at this stuff :) |
Oooh this is was caused by #56130. Thanks for the ping! I'll see what can be done to fix it. |
+1 thanks for the ping! Interestingly, running a 6.4 test site without Gutenberg active, I'm seeing the issue on that WP version, too, where the I very well could be missing something in my test setup though! |
@andrewserong is your |
Yes! Here's the markup from my screenshot: <!-- wp:group {"align":"full","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull"><!-- wp:cover {"overlayColor":"accent","isUserOverlayColor":true,"align":"wide","layout":{"type":"constrained"}} -->
<div class="wp-block-cover alignwide"><span aria-hidden="true" class="wp-block-cover__background has-accent-background-color has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">A cover block</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover --></div>
<!-- /wp:group --> |
Going to list this as a "to do" item for 6.5.x in hopes we can perhaps get a fix. Thanks so much for reporting btw @andersnoren ❤️ |
@tellthemachines, I just had an idea for a potential fix. Would it work to skip some of the base layout output if there's no content or wide size set in the global layout settings object? I was thinking something like the following (around line 1617 of // Skip rules that reference content size or wide size if they are not defined in the theme.json.
if (
is_string( $css_value ) &&
( str_contains( $css_value, '--global--content-size' ) || str_contains( $css_value, '--global--wide-size' ) ) &&
! isset( $this->theme_json['settings']['layout']['contentSize'] ) &&
! isset( $this->theme_json['settings']['layout']['wideSize'] )
) {
continue;
} I can put that into a draft PR if you like, but I don't feel at all strongly about it if you had other ideas for a fix 🙂 |
@andrewserong that should work, yes, thanks! |
This update broke hundreds of websites. I have this in my
I also have these in my
How do I fix it? What rules do I need to add to my CSS stylesheet? |
@wolffe this should be fixed in WordPress 6.5.3 which was released yesterday. Can you upgrade and confirm if this remains a problem? |
No, this was has been working for years, and WordPress 6.5.3 broke hundreds of sites I manage. I had to manually add CSS to my theme to bring it back to the way it was before. |
Oh, what a fascinating problem, thanks for bringing this up @wolffe.
Are there particular things that broke, that could help debug what's happened? My understanding is that the content and wide size CSS variables are controlled ones from the perspective of WordPress' output, and so the logic that was recently introduced (to resolve other bugs) was to only output rules that depend on those variables if those variables are being output. The canonical way to ensure those rules are output is to include a small If you're looking for a short-term solution to restore the behaviour you were expecting for this particular case, another potential option could be to manually add within your theme the rules that are no longer being output. In this case, I believe that would be something like:
However, if your theme depends on content and wide sizes, I'd recommend exploring adopting If you're looking for a reference of the kinds of rules that get output for layout styles in general (in case there are additional rules required for your theme), you might be interested in checking the layout definitions defined in core here: https://github.com/WordPress/wordpress-develop/blob/5466d3a9a72b38039ded378ae0f7331e8ba32a3f/src/wp-includes/block-supports/layout.php#L21 All that said, that's just my perspective as one contributor in this area. I'll also ping @tellthemachines for visibility. |
Thanks for the ping! As @andrewserong mentioned above, |
After updating to WordPress 6.5.3, I cannot have a constrained block inside a full width cover or group. I cannot do what's illustrated in the image below: I have a classic theme, and I am not interested in switching to a block theme, or FSE, or Site Editor, or anything like that. My only option right now is to switch back to 6.5.2, get the CSS styles and hardcode them into my theme. But I shouldn't need to do this. Is it going to be impossible for a classic theme to have constrained blocks inside full width covers or groups? |
Unfortunately I'm not sure I understand what the underlying issue is here. From testing a few of the different core Classic themes, that kind of layout appears to be achievable with how those themes implement their styling and theme supports. E.g. here's using full and wide width Cover blocks in Twenty Twenty theme: As a result, my hunch is that the theme(s) in question are depending on parts of the behaviour of global styles rather than providing their own rules (which I believe is the traditional way that Classic themes handle content widths, etc).
Adopting a For example, in the root directory of a theme, a simple
Adding that file wouldn't convert the theme into being a block theme, the site editor will still be inaccessible, but the layout content and wide sizes (and the styles that use them) would now be output. While the concept of hybrid themes isn't a formal distinction, it's a pragmatic term to capture just this kind use case, where a classic theme exists, but there's an aspect of how global styles works that's still useful for such a theme. From the docs:
Hope that helps! |
The problem is that the styles that were there previously (for years, I'd say) have been removed in WordPress 6.5.3. The solution is for me to add those styles, but then what's the point of having a full-width block which is not working out of the box? Also, why was this removal needed? |
I understand the change here is causing an issue for themes that have been developed in that way. From what you've described so far, unfortunately the approach that's been used in those themes does not match how the layout support is intended to work.
This is a nuanced issue, but this isn't exactly the case. The logic has changed in terms of when the styles are output, and the styles that were output depend on particular CSS variables that are generated by core. The fix in #60489 resolved a different conflict that also affected many themes.
It works out of the box for classic and block themes that define content and wide sizes via a
Unfortunately, I'm not sure I have too much to add here beyond the current issue description and the linked PR (#60489) that skipped outputting the rules, as I believe they cover most of the context. WordPress 6.5 moved to applying the layout classnames where they're intended to be applied (the direct wrapper for inner blocks) in #56130, and this issue's description describes the bug that resulted. This exposed that the layout styles that reference CSS variables were being output when they shouldn't (for themes that aren't defining content and wide sizes), which suggested the path forward of #60489. The recommended solution, if you're wishing to use the rules output by core, is to add a If there are further issues or logic that should tweaked, do feel free to open an issue. Getting layout styles to work properly in all expected situations is particularly challenging, and it's very helpful to have more context and details on how the features are being used. |
Description
In classic themes in WordPress 6.5, the maximum width of
alignwide
blocks are overwritten when they're direct descendants of a group block set to the "Full" alignment.Many classic themes built after the block content editor was introduced set the maximum width of
alignwide
blocks with CSS, like this:When running a classic theme without theme.json in WordPress 6.5 and including a wide block inside a full group, Core outputs the following CSS even though the
--wp--style--global--wide-size
variable is undefined:This results in the
alignwide
maximum width set by the theme CSS being overwritten by the undefined variable, breaking the layout. I've replicated this in Twenty Twenty and in two of my classic themes (Chaplin and Eksell).Expected behavior
The CSS above should not be output if
--wp--style--global--wide-size
is undefined. Given the high specificity of the CSS generated by Core, I'd expect this to affect many classic themes that set a maximum width foralignwide
with CSS.Step-by-step reproduction instructions
.wp-block-group__inner-container
div, instead of maxing out at the120rem
maximum width set by the Twenty Twenty CSS..alignwide
is overwritten by the CSS generated by Core, included above.Screenshots, screen recording, code snippet
In the screenshots, the black group is set to full and the red is set to wide.
Block markup
Environment info
WordPress 6.5
With or without Gutenberg active
Twenty Twenty 2.6
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: