Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout: top margin overwrites theme.json block CSS when gap support enabled #35411

Closed
ramonjd opened this issue Oct 7, 2021 · 2 comments
Closed
Labels
[Block] Columns Affects the Columns Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended

Comments

@ramonjd
Copy link
Member

ramonjd commented Oct 7, 2021

Description

Since Gutenberg 11.7 (in #34491), the gutenberg_get_layout_style method adds the following CSS to .wp-block-post-content children and their adjacent siblings where block spacing support (A.K.A blockGap) is enabled:

> * + * {
    margin-top: var( --wp--style--block-gap );
    margin-bottom: 0;
}

See layout.php.

Block spacing support was introduced in #33991.

For blocks that have opted-in to block spacing, such as the Columns block or in the PR for the Social Links block, this CSS's specificity overwrites any block-specific top and bottom margins in theme.json.

Noticed by @stacimc when testing #35374 (comment) 👍

Step-by-step reproduction instructions

Set a top and bottom margin for the core/columns block in your theme.json

       ...
	"styles": {
                 ...
		"blocks": {
			"core/columns": {
				"spacing": {
					"margin": {
						"top": "20px",
						"bottom": "30px"
					}
				}
			}
		}
	}

In a new post, insert a Columns Block as a second block, for example, insert a paragraph first, then columns.

Save the post and inspect the styles.

What I expected

The theme.json styles would take precedence over any plugin-generated block layout styles.

What happened

The plugin-generated block layout styles take precedence. See screenshot below.

Screenshots, screen recording, code snippet

Screen Shot 2021-10-07 at 11 34 10 am

Environment info

  • WordPress 5.8, Gutenberg 11.7, TT1 Blocks

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

@ramonjd ramonjd added [Block] Columns Affects the Columns Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended CSS Styling Related to editor and front end styles, CSS-specific issues. labels Oct 7, 2021
@ulziibat-n
Copy link

I have the same problem.

@ramonjd
Copy link
Member Author

ramonjd commented Oct 4, 2022

Closing. Cannot reproduce as of 14.3

@ramonjd ramonjd closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants