gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Block Group: Missing alignment options and styles when using a Classic theme

Open arpadkdweb opened this issue 2 years ago • 16 comments

Description

Pattern editor in classic theme does not allow wide and full alignment options whether it's a synced or unsynced pattern. I expect the same block supports settings to be available in the pattern editor as in the post editor.

Also, it makes sense to create patterns or even complex full page pattern templates that go full width.

The pattern in my classic theme is constrained to container width.

Step-by-step reproduction instructions

  1. Go to appearance > patterns
  2. Add a group block or any block that supports wide or full alignment
  3. The settings are missing from the icon toolbar
  4. If you try to add the same block in a post editor, the alignment options appear

Screenshots, screen recording, code snippet

Pattern editor image

Post editor image

Environment info

  • WordPress 6.5.3
  • Using a custom classic theme (site editor is disabled), but reproducable in twentytwentyfour as well
  • Tried with Gutenberg 18.4.1 and without as well

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

arpadkdweb avatar Jun 05 '24 10:06 arpadkdweb

I can confirm this. When used with a classic theme, the Group block does not have alignment options or styles.

This is what I see in block themes: Screen Shot 2024-06-19 at 10 59 02

This is what I see on classic themes. Screen Shot 2024-06-19 at 10 56 40

I am adding the "regression" label tentatively but perhaps classic themes never supported these settings on the group block?

mrfoxtalbot avatar Jun 19 '24 12:06 mrfoxtalbot

I stumbled upon the same issue. It’s working for me as long as there is no theme.json available.

Test theme:

style.css:

/*
Theme Name: TEST
Description: Test
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: test
Update URI: false

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

functions.php:

<?php
function test_setup() {
	// add Gutenberg wide and full content support
	add_theme_support( 'align-wide' );
}

add_action( 'after_setup_theme', 'test_setup' );

As soon as you add a theme.json, the alignment controls are missing for patterns, even if it just contains this:

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2
}

MatzeKitt avatar Jun 21 '24 10:06 MatzeKitt

I can confirm this. When used with a classic theme, the Group block does not have alignment options or styles.

This is what I see in block themes: Screen Shot 2024-06-19 at 10 59 02

This is what I see on classic themes. Screen Shot 2024-06-19 at 10 56 40

I am adding the "regression" label tentatively but perhaps classic themes never supported these settings on the group block?

Even if I create a new block that is supposed to have support for wide and full alignment, that new block still doesn't work. So I believe this is a buggy behaviour.

arpadkdweb avatar Jun 21 '24 10:06 arpadkdweb

Ok so, I could be wrong but this seems to be expected https://developer.wordpress.org/themes/global-settings-and-styles/settings/appearance-tools/

Classic themes will not have support for this unless they state it explicitly. I do not have the full context but I imagine this was done to prevent unintended layout consequences. In this sense, I would not consider it a bug.

mrfoxtalbot avatar Jun 21 '24 13:06 mrfoxtalbot

I suggest closing this issue as "wont fix", but I would like to hear from you all first.

mrfoxtalbot avatar Jun 21 '24 13:06 mrfoxtalbot

It’s at least a regression since we use this system as is quite a while and I guess it was in WordPress 6.5 when the appearance tools got removed from the toolbar in such cases. Before that, it worked fine.

And I would assume that using add_theme_support for align-wide should be considered to override the default of the theme.json, since it does it in the regular editor and solely does not for patterns. That would be inconsistent.

MatzeKitt avatar Jun 21 '24 14:06 MatzeKitt

And, unfortunately, explicitly setting appearanceTools to true doesn’t change the behavior whatsoever. 😞

At least when it comes to the alignment setting in the block toolbar.

MatzeKitt avatar Jun 21 '24 14:06 MatzeKitt

I believe this is a weird inconsistency and makes using the pattern editor in classic themes simply a bad experience, as the admin view will not reflect how the pattern will behave on the frontend or even when inserted in a page in the backend.

I think the expected behaviour should be the same as in the post editor. So if a block supports wide or full alignment the pattern editor should reflect that.

arpadkdweb avatar Jun 21 '24 14:06 arpadkdweb

Thank you for checking and re-testing @MatzeKitt & @arpadkdweb. I will admit I am a bit out of my depth here. @MaggieCabrera, could you help us get some more context here?

mrfoxtalbot avatar Jun 26 '24 05:06 mrfoxtalbot

I have the same problem,

I want to use wordpress patterns. However, I don’t have the alignwide and alignfull options on blocks (including native blocks like the gallery).

Our WordPress themes work with theme.json, so the add_theme_support( ‘align-wide’ ) function is not interpreted. And if I delete the theme.json and implement this function, the alignfull and alignwide options are available again.

Also, when testing with the Twenty Twenty-Four theme, the options are available. FSE themes don’t seem to have this problem.

In fact, the custom post type ‘wp_block’ is considered like a DESIGN_POST_TYPES. Cf comment: https://github.com/WordPress/WordPress/blob/6.5.5/wp-includes/js/dist/editor.js#L15463 To have the alignwide and alignfull alignment options, the layout must be of type ‘constrained’ or it is of type ‘default’.

ccharel avatar Jul 08 '24 10:07 ccharel

Considering we are going to enable patterns on Classic themes in 6.6, it would be good to get some clarity on this one

Could you help us here, @jasmussen? Thank you!

mrfoxtalbot avatar Jul 09 '24 14:07 mrfoxtalbot

Is this issue similar to https://github.com/WordPress/gutenberg/issues/62516? If yes, there's some discussion there that might be useful to dive into. Otherwise I would recommend a broader ping, along the lines of gutenberg-core.

jasmussen avatar Jul 09 '24 15:07 jasmussen

Is this issue similar to https://github.com/WordPress/gutenberg/issues/62516?

I think this is the same issue described here, though the name is deceptive - it applies to any pattern created in a classic theme with theme.json.

And, unfortunately, explicitly setting appearanceTools to true doesn’t change the behavior whatsoever. 😞

The documentation on that page lists the following as affected by setting "appearanceTools": true: border, color, dimensions, position, spacing, typography. Layout is not included. Elsewhere, the docs imply that setting the content/wide size in the layout key should opt you into using it. However, in my testing, this bug still occurs in a classic theme with a layout key present in theme.json.

Reiterating, it is very confusing that if you select a block with an alignment and create a synced pattern with it then the alignment is preserved and displayed on the front end, but there is no longer a way to edit it.

cbirdsong avatar Sep 17 '24 20:09 cbirdsong

+1 I agree that the absence of root level alignment tools in the pattern editor is quite confusing. Having alignment options at least as an opt-in setting in theme would improve pattern usability.

I couldn't find discussion round decision to disable layout styles from design post types (../wp-includes/js/dist/editor.js). So it would be great if someone can share the original idea behind this.

veerap000 avatar Aug 13 '25 13:08 veerap000

it would be great if someone can share the original idea behind this

I agree - it makes very little sense that alignment controls in the pattern editor wouldn't behave exactly like the editor does in other contexts since patterns can be inserted almost anywhere.

cbirdsong avatar Sep 09 '25 21:09 cbirdsong

Thanks for the report and all the investigation here, @arpadkdweb! The same problem, wide/full alignment controls missing for blocks in the pattern editor, is tracked in #70545, where @talldan proposed making the alignment tools available for top-level blocks in the isolated editor, so I'm closing this one as a duplicate.

youknowriad avatar Oct 20 '26 10:10 youknowriad