WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.56k stars 4.22k forks source link

Set Parent Group block alignment while editing Template Part #34010

Open richtabor opened 3 years ago

richtabor commented 3 years ago

Is there an existing issue for this?

Have you tried deactivating all plugins except Gutenberg?

Have you tried replicating the bug using a default theme e.g. Twenty Twenty?

Description

I should be able to modify a parent group block's alignment width setting (wide/full) when editing a template part in a template part's editor view within the Site Editor.

When applying a background color in the template part editor view, it seems the group block is 100%— but here's what we get instead:

Screen Shot 2021-08-11 at 8 44 28 AM

So I went to ensure it was set to alignfulll, but the template editor view would not allow it. However, I could go into the standard Site Editor view (editing the singular template for example) and I was able to properly set the width to alignfull.

Step-by-step reproduction instructions

  1. Go to a template part within the Site Editor
  2. Attempt to set wide/full width (not possible as the Group block's controls are missing)
  3. Go to a template part on a template, such as Singular
  4. Attempt to set wide/full width (possible).

Expected Behavior

I can set alignfull/alignwide while editing a specific template part.

Current Behavior

The align controls are missing (wide/full) when viewing a template part within its own edit view.

Screenshots or screen recording (optional)

Editing a template part within the Site Editor > Singular template (works):

Screen Shot 2021-08-11 at 8 40 36 AM

Editing a template part on its own view:

Screen Shot 2021-08-11 at 8 43 22 AM

Code snippet (optional)

No response

WordPress Information

5.8

Gutenberg Information

11.2.1

What browsers are you seeing the problem on?

No response

Device Information

No response

Operating System Information

No response

DaisyOlsen commented 2 years ago

I've run into this issue and wondered if it was intentional or not. From a theme development standpoint the ability to set full and contained widths via the site editor feels pretty important.

MadtownLems commented 1 year ago

The inability to use Full-Width blocks in Template Parts is causing some headaches for us and our hybrid theme.

A simple use case is that we have a Template Part above the primary post listing. We absolutely want folks to be able to use full width blocks here, but it seems impossible.

MadtownLems commented 1 year ago

I'm attaching an example of what we're trying to do, which seems impossible due to #30079

2023-04-04 15_52_34-Hybrid Theme Test Site – University of Wisconsin – Madison

ndiego commented 2 weeks ago

While this does not fully address the main issue, you can use full-width blocks within a template part. The key is you need to set the template part to "align":"full" if it's contained within another Group block.

Image

The markup for the template part in the above screenshot using TT5 is:

<!-- wp:template-part {"slug":"footer-3","theme":"twentytwentyfive","align":"full"} /-->
MadtownLems commented 2 weeks ago

While this does not fully address the main issue, you can use full-width blocks within a template part. The key is you need to set the template part to "align":"full" if it's contained within another Group block.

Unfortunately, I don't think that helps in the case of theme-provided Template Parts, which is our situation. :/

ndiego commented 1 week ago

Ah this is due to the issue @carolinan described in the contributor notes on the block_template_part() docs page. When rendering a block template part in a PHP template the wrapper element is not rendered, only the content inside of the template part. Because of this, you cannot apply "align":"full" to the template part itself as I suggested, and as you would do in a block theme. I'm not sure about the backward compatibility implications, but it feels like the block_template_part() should be fixed to increase parity between the classic and block theme implementations.

Right now you would render a 404 template like:

 block_template_part( '404' )

But perhaps the function could be expanded to something like:

block_template_part( string $part, boolean $wrapper, array $wrapper_args )