Skip to content

Post Content: Layout styles not applied in editor (e.g. Social Icons, Buttons, etc.) #35376

@ramonjd

Description

@ramonjd

Description

The Social Icons Block doesn't receive the appropriate layout styles in the Post Content Block/Site Editor.

In the Block Editor, things look great.

By default the Social Icons block container has the following layout block support styles in the Block Editor:

{
    display: flex;
    gap: var( --wp--style--block-gap, 0.5em );
    flex-wrap: wrap;
    align-items: center;
}

Since #32083 we're rendering these styles via wp_footer in lib/block-supports/layout.php.

However since the styles are no longer rendered inline, and therefore no longer part of the post content, the Post Content Block does not retrieve them. Reverting this change sees things working as expected.

This is because the Post Content Block renders server-side, and uses the REST API to fetch the post content. The REST API’s response doesn’t include wp_footer, so the layout styles are not passed along.

Step-by-step reproduction instructions

  1. In a site where your homepage displays your latest posts, insert a new post and add a Social Icons Block in the Block Editor.
  2. Add a bunch of social media icons. The icons should display in a flex layout, with the appropriate layout styles applied to the container.
  3. Save the file, then open up the Site Editor.
  4. Observe that the Social Icons block does not have the required layout styles applied to the container.

Screenshots, screen recording, code snippet

Block Editor
Screen Shot 2021-10-06 at 12 17 14 pm

Site Editor

Displayed within a Post Content Block

Screen Shot 2021-10-06 at 12 17 21 pm

Environment info

  • WP 5.8, Gutenberg 11.7, TT1 theme

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

Metadata

Metadata

Assignees

Labels

CSS StylingRelated to editor and front end styles, CSS-specific issues.[Block] Post ContentAffects the Post Content Block[Block] SocialAffects the Social Block - used to display Social Media accounts[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions