pfefferle / autonomie

"Autonomie" is a highly semantic, responsive, accessible and search engine optimized WordPress Theme. It provides HTML5 templates refined with microformats, microformats v2 and microdata (Schema.org). "Autonomie" supports a lot of OpenWeb plugins and is fully IndieWeb compatible.
https://notiz.blog/projects/autonomie/
MIT License
96 stars 21 forks source link

Gutenberg Columns block does not display as flex due to over-specific CSS rule #57

Closed SpencerDub closed 3 years ago

SpencerDub commented 3 years ago

Issue summary

If you create a Columns block in the Block Editor, it will not display properly in the published post. Instead of creating horizontal columns as intended, the content of each column is just displayed as a block. Looking at the source, the column container element is rendered as display: block instead of display: flex.

Steps to reproduce

  1. Create a new page or post in the Block Editor
  2. Create a Columns block. For my testing purposes, I created one with two columns, one 33% wide, the other 66% wide.
  3. Put content in both columns.
  4. Preview or publish the post. You can see a sample of this here.

Expected outcome

The Columns block renders as a series of columns—the columns are displayed horizontally next to each other when there is sufficient horizontal space. The Columns container <div> is rendered with display: flex.

Actual outcome

Regardless of how wide the window is, the content of the columns is simply displayed as block elements, so what would be the first and second columns are instead just displayed vertically in that order. The source indicates the column container element is rendered as display: block.

Further notes

The SASS file responsive_default.scss is too specific on line 34. It reads (relevant parts only):

.entry-content > *, .entry-content > div {
    display: block;
}

This takes priority over the CSS rule that should designate this container <div> as display: flex, from style.min.css:

.wp-block-columns {
    display: flex;
    margin-bottom: 1.75em;
    flex-wrap: wrap;
}
SpencerDub commented 3 years ago

I've hacked together a solution by adding the line .wp-block-columns {display: flex !important;} in my child theme's CSS, but this is really inelegant. If someone else has better ideas on how to resolve this upstream, I'm all ears.

pfefferle commented 3 years ago

Do you use the latest version of Autonomie? I think I have fixed it a while ago: https://github.com/pfefferle/autonomie/blob/bef825ec84d7b8aff61eec4c57c010d208d836ad/assets/sass/responsive_default.scss#L37

@SpencerDub can you verify this?

SpencerDub commented 3 years ago

Ah! Updating seems to have fixed this. Sorry I missed that, @pfefferle.