Skip to content

Full width of template does not get displayed in Post Editor when Post Content block is in a group #64149

Closed

Description

@luminuu

Description

Based on feedback I got and my own testing, I found that when editing a page in the Post Editor and the template it's using has the Post Content block nested in a group, the content on the Post Editor is not showing in full width, but in a constrainted view. It works all fine in the site editor and the frontend though.

It makes a difference if the post content block is on the top level of the template vs. if the post content block is nested within a group. If the latter is happening, the following code is applied in the post editor:

.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: 620px;
    margin-left: auto !important;
    margin-right: auto !important;
}

The 620px is the content size of TT4, where I tested this with. I can reproduce this problem with the Greyd WP theme as well, so it's not happening in the theme but in the editor. In the post editor, it's impossible to assign any of the alignment classes to a top level element.

The reason why the post content block has to be in a group is that this group has to be set to use the main tag, as otherwise the skip link is not going to be generated by WP, as it requires a main tag in the code. For testing, see the Greyd WP theme template "Blank", which has the exact setup that I used this to test with.

Step-by-step reproduction instructions

  1. Use an existing template or create a new template
  2. Add a Post Content block in it, disable "Inner blocks use content width"
  3. Put the Post Content block in a group and also disable "Inner blocks use content width" on the group
  4. Create a page that uses this template
  5. Open this new page from the post editor (not the site editor!)
  6. Add some blocks, preferrably with a background color
  7. Confirm that the blocks are not displayed in full width

Screenshots, screen recording, code snippet

(Video has audio)

CleanShot.2024-07-31.at.18.33.40-converted.mp4

Environment info

  • WordPress 6.6.1
  • Twenty Twenty-Four 1.2
  • Gutenberg 18.8.0 not installed, but it does not make any difference if Gutenberg is installed

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

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    General InterfaceParts of the UI which don't fall neatly under other labels.
    CSS StylingRelated to editor and front end styles, CSS-specific issues.
    on Jul 31, 2024
  2. richtabor commented on Jul 31, 2024

    @richtabor
    Member

    It makes a difference if the post content block is on the top level of the template vs. if the post content block is nested within a group.

    I'm able to replicate this as well.

  3. colorful-tones commented on Sep 10, 2024

    @colorful-tones
    Member

    I've narrowed down where this is being triggered, but I'm not sure how/why the code is doing what it is doing.

    !! contentSize || !! wideSize
    ? `
    ${ appendSelectors(
    selector,
    '> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
    ) } {
    max-width: ${ contentSize ?? wideSize };
    margin-left: ${ marginLeft };
    margin-right: ${ marginRight };
    }
    ${ appendSelectors( selector, '> .alignwide' ) } {
    max-width: ${ wideSize ?? contentSize };
    }
    ${ appendSelectors( selector, '> .alignfull' ) } {
    max-width: none;
    }
    `
    : '';

  4. Peeeet commented on Sep 23, 2024

    @Peeeet

    Is there a workaround or recommended way to mitigate this? I have found that deleting layout { contentSize, wideSize } entries from theme.json seems to change this behavior (makes it fill the full width of the post editor - even ignoring horizontal padding and margins) but neither that "fix" nor the results seem ideal...

  5. ndiego commented on Oct 9, 2024

    @ndiego
    Member

    Given that this is not specifically related to WordPress 6.7 and how late we are in the 6.7 release cycle, I am punting this to 6.8.

  6. moved this from 📥 Todo to 🏈 Punted to 6.8 in WordPress 6.7 Editor Taskson Oct 9, 2024
  7. youknowriad commented on Dec 3, 2024

    @youknowriad
    Contributor

    Ok, here are my findings today: The dichotomy in rendering is not between "post editor" and "site editor". It's between whether "show template" is used or not (you can check/uncheck it in the preview options).

    • When the template is show, the rendering is correct.
    • When the template is not shown, the rendering is always constrained to the "centered" area.

    I think this behavior is actually the expected behavior. This was discussed in length in a previous issue I believe (@jasmussen might remember it) and the idea is that when "show template" is disabled, it's an "abstracted view" that doesn't match entirely what's around the "post content". Some templates might have sidebars, some others might split the view in three columns or two and the post content occupying just a small part of it, other templates might be full width like here. We can't "replicate" that unless the template is actually rendered.

    I hope this answers this issue properly. My suggestion is to close this issue as working as intended.

  8. luminuu commented on Dec 3, 2024

    @luminuu
    MemberAuthor

    @youknowriad Thank you for your feedback. If this is the expected behaviour, can we then think about having an option to show the contents in full width? I can understand it's working as intended, but I've come across this multiple times now when the user expectiation is "I want to see this in full width", even if it's restricted in the actual front-end view. Sometimes it makes sense to have the contents shown in full width if they're in separate templates. I'm not very much a fan of hard-coding CSS to overwrite this in a plugin, but this is what I've been trying to make it work for the user.

  9. youknowriad commented on Dec 3, 2024

    @youknowriad
    Contributor

    @luminuu Can you help me understand why the "show template" toggle is not a good solution for this? I want to note that this toggle is enabled by default for "pages" in Gutenberg trunk (next WP version)

  10. jasmussen commented on Dec 4, 2024

    @jasmussen
    Contributor

    The video demo is compelling because it focuses on just a very specific subset of theme design, where the theme itself uses a centered column, and a use case for a full edge to edge page template is argued for.

    However I would agree with Riad that "Show template" is the existing fix for this, for a few reasons, the main being the fact that unless you have "Show template enabled", then the template isn't actually loaded at all. That means for far more complex layouts, notably the multi-column ones that feature a sidebar, and thus toggle off "Inner blocks use content width", the post editor cannot predict at all, what the end result should be: because the template isn't loaded, the post editor doesn't know that the post content is supposed to show up in a column.

    Image

    These layouts are more common than you think. Which means that if we change this behavior, those themes will have edge-to-edge post content, which is:

    • A terrible writing/reading experience
    • Not anywhere near WYSIWYG
    • Inaccessible

    So at the core of this issue is the acknowledgement that the post editor is an abstracted editor. It's WYSIWYG when it can be, but what it shows is still just what's inside post content. If you want true full-page WYSIWYG, you have to toggle on "Show template".

  11. youknowriad commented on Dec 4, 2024

    @youknowriad
    Contributor

    Per the previous comments, I'm going to close this issue as it's working as intended.

  12. moved this from 🏈 Punted to 6.8 to ✅ Done in WordPress 6.7 Editor Taskson Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CSS StylingRelated to editor and front end styles, CSS-specific issues.General InterfaceParts of the UI which don't fall neatly under other labels.[Feature] LayoutLayout block support, its UI controls, and style output.[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions