Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Blockbase: Remove alignment styles #4454

Closed
wants to merge 2 commits into from

Conversation

scruffian
Copy link
Member

@scruffian scruffian commented Aug 23, 2021

This is an alternate approach to #4448

Gutenberg has changed so that now all group blocks have the wp-container-* class. This means that we can no longer rely on this class to target elements that are meant to "inherit layout".

This PR removes all the alignment styles that are trying to change the way that Gutenberg handles alignments. It has become very difficult to modify the default behaviour in the theme.

The one case that I think we should try to handle is this: #3747

The problem with adding padding to paragraph blocks inside alignfull elements is that you can add alignfull to elements that "inherit layout", which means that they no longer align to the edge of the layout container.

So instead of setting padding on these elements we can set a max width on this. However the problem with this approach is that elements inside "inherit layout" containers also use max-width to constrain them to the correct column size.

So instead this PR proposes that we use width to constrain all paragraphs. This will allow "inherit layout" to continue behaving as before, but it will ensure that paragraph blocks don't ever touch the edge of the screen.

To test you can use the markup in #4448 and #4412.

@scruffian scruffian requested a review from a team August 23, 2021 12:12
@scruffian scruffian self-assigned this Aug 23, 2021
@MaggieCabrera
Copy link
Contributor

I tried this one with the same demo content I pasted over at #4448 and this is what I get:

Screenshot 2021-08-23 at 15-56-59 Alignments – free
Screenshot 2021-08-23 at 15-56-46 Alignments – free

Copy link
Contributor

@jffng jffng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gutenberg has changed so that now all group blocks have the wp-container-* class. This means that we can no longer rely on this class to target elements that are meant to "inherit layout".

Especially given this ^, I am generally in favor of removing alignment styles from Blockbase.

That said, I don't think the width approach will work because of the comment I made below. I tested with this content: https://theamdemo.wordpress.com/2021/08/23/gutenberg-alignment/

// An alternative to padding.
margin-left: auto;
margin-right: auto;
width: calc( 100vw - var(--wp--custom--post-content--padding--left) - var(--wp--custom--post-content--padding--right) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a width here causes paragraphs to sometime overflow out of their containers:

Screen Shot 2021-08-23 at 2 28 56 PM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense. i think we should just remove it all

@pbking
Copy link
Contributor

pbking commented Aug 24, 2021

Closing in lieu of #4459

@pbking pbking closed this Aug 24, 2021
@pbking pbking deleted the remove/alignment-styles-from-blockbase branch September 28, 2021 02:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants