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

Block spacing/layout/is-layout-flow: Top margin also added inside flex items #49914

Closed
jasmussen opened this issue Apr 19, 2023 · 17 comments
Closed
Labels
[Block] Columns Affects the Columns Block [Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended

Comments

@jasmussen
Copy link
Contributor

When a container block has "flow" layout, its innerblocks are subject to this CSS:

:where(body .is-layout-flow) > * {
    margin-block-start: 1.5rem;
    margin-block-end: 0;
}

There seems to be missing something like this, or at least in the use case I'm about to describe, it's not taking hold:

:where(body .is-layout-flow) > *:first-child {
    margin-block-start: 0;
}

What I'm seeing is that when using any block inside a columns block, top margin is applied to the first block inside. Take the following example

Screenshot 2023-04-19 at 09 44 16

That's 3 columns with background colors, and a "Test" Cover block in the 3rd column. As you can see there's top margin applied there, when there shouldn't be:

Screenshot 2023-04-19 at 09 44 32

I can zero that out using the margin tool on the cover, but I shouldn't have to. The first block in a stack should not have top margin.

Example code:

<!-- wp:columns {"style":{"spacing":{"blockGap":{"top":"0","left":"0"}}}} -->
<div class="wp-block-columns"><!-- wp:column {"backgroundColor":"primary"} -->
<div class="wp-block-column has-primary-background-color has-background"><!-- wp:paragraph -->
<p>1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>2</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

<!-- wp:column {"backgroundColor":"tertiary"} -->
<div class="wp-block-column has-tertiary-background-color has-background"><!-- wp:paragraph -->
<p>1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>2</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>3</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

<!-- wp:column {"style":{"spacing":{"padding":{"top":"0","right":"0","bottom":"0","left":"0"}}},"backgroundColor":"secondary","textColor":"base"} -->
<div class="wp-block-column has-base-color has-secondary-background-color has-text-color has-background" style="padding-top:0;padding-right:0;padding-bottom:0;padding-left:0"><!-- wp:cover {"overlayColor":"pale-cyan-blue","minHeight":100,"minHeightUnit":"%","isDark":false,"style":{"spacing":{"blockGap":"0px"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-cover is-light" style="min-height:100%"><span aria-hidden="true" class="wp-block-cover__background has-pale-cyan-blue-background-color has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
@jasmussen jasmussen added [Type] Bug An existing feature does not function as intended [Block] Columns Affects the Columns Block [Feature] Layout Layout block support, its UI controls, and style output. labels Apr 19, 2023
@jasmussen
Copy link
Contributor Author

@tellthemachines do you have any insights here? Thank you for looking.

@tellthemachines
Copy link
Contributor

Hmm, not sure what's happening there. I can't reproduce it with the test markup on TT3 or Empty theme. This is what I see:

Screenshot 2023-04-20 at 12 18 46 pm

The rule that removes the top margin from the first element should be specific enough to work anywhere: .editor-styles-wrapper :where(body .is-layout-flow) > :first-child:first-child. I wonder if that rule isn't being output for some reason?

@jasmussen
Copy link
Contributor Author

We could use a unified "let's improve labels-only mode" ticket where we can track some of the possible improvements that surface here and there. For me the one that keeps coming up is when we're using the tooltip for the label, causing it to be very very long. For example, "Apply duotone filter" should just be "Duotone".

@jasmussen
Copy link
Contributor Author

The rule that removes the top margin from the first element should be specific enough to work anywhere: .editor-styles-wrapper :where(body .is-layout-flow) > :first-child:first-child. I wonder if that rule isn't being output for some reason?

Yes, I'm not sure what's going on here. I'm testing, and previewing in the post editor, using a variation of the TT3 theme. But testing now, I'm also seeing it in the site editor:

Screenshot 2023-04-20 at 13 30 51

Here's the CSS that takes:

Screenshot 2023-04-20 at 13 29 54

I'm seeing a :first-child:first-child rule work for the site header, which is indeed the first block in the page:

Screenshot 2023-04-20 at 13 30 38

But that's not the same CSS as you are showing a screenshot of here, I'm seeing the following:

Screenshot 2023-04-20 at 13 30 29

I can also confirm that if I manually add the CSS you have in your screenshot, it's working for me:
Screenshot 2023-04-20 at 13 34 23

Screenshot 2023-04-20 at 13 34 28

So for whatever reason the CSS isn't output for me 🤔

@tellthemachines
Copy link
Contributor

is it possible that for some reason that block wrapper isn't the first child of its parent?

@jasmussen
Copy link
Contributor Author

That was my first instinct, but it doesn't seem to be the case unless I'm doing something wrong. Here a gif showing how I set the margin on every first child inside each column to zero in order for it to take:

testing

Here's the dom, which also looks like the first child rule should be present:

Screenshot 2023-04-21 at 09 09 58

@tellthemachines
Copy link
Contributor

I'm not quite sure what's happening here as I can't reproduce it locally. From the total absence of the first-child style it could be a caching issue similar to #45713, but in that case it's very odd that .editor-styles-wrapper :where(body .is-layout-flow) > * is appearing, because both those styles were updated at the same time and are generated from theme.json layout definitions.

To help debug, could you share the content of the style tag where the main style is coming from? By clicking on <style> in the upper right corner here:
Screenshot 2023-04-24 at 10 10 12 am and then "copy element" on the style tag itself:

Screenshot 2023-04-24 at 10 33 07 am

@jasmussen
Copy link
Contributor Author

Sure, here you go. This is from the editor, to be clear, not that it should necessarily diverge too much:

Code snippet
<style>.editor-styles-wrapper {
margin: 0;
--wp--style--global--content-size: 540px;
--wp--style--global--wide-size: 1200px;
}

.editor-styles-wrapper .wp-site-blocks {
padding-top: var(--wp--style--root--padding-top);
padding-bottom: var(--wp--style--root--padding-bottom);
}

.editor-styles-wrapper .has-global-padding {
padding-right: var(--wp--style--root--padding-right);
padding-left: var(--wp--style--root--padding-left);
}

.editor-styles-wrapper .has-global-padding :where(.has-global-padding) {
padding-right: 0;
padding-left: 0;
}

.editor-styles-wrapper .has-global-padding > .alignfull {
margin-right: calc(var(--wp--style--root--padding-right) * -1);
margin-left: calc(var(--wp--style--root--padding-left) * -1);
}

.editor-styles-wrapper .has-global-padding :where(.has-global-padding) > .alignfull {
margin-right: 0;
margin-left: 0;
}

.editor-styles-wrapper .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),
.editor-styles-wrapper .wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) {
padding-right: var(--wp--style--root--padding-right);
padding-left: var(--wp--style--root--padding-left);
}

.editor-styles-wrapper .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),
.editor-styles-wrapper .wp-block:not(.alignfull),p,h1,h2,h3,h4,h5,h6,ul,ol) {
padding-right: 0;
padding-left: 0;
}

.editor-styles-wrapper .wp-site-blocks > .alignleft {
float: left;
margin-right: 2em;
}

.editor-styles-wrapper .wp-site-blocks > .alignright {
float: right;
margin-left: 2em;
}

.editor-styles-wrapper .wp-site-blocks > .aligncenter {
justify-content: center;
margin-left: auto;
margin-right: auto;
}

.editor-styles-wrapper :where(.wp-site-blocks) > * {
margin-block-start: 1.5rem;
margin-block-end: 0;
}

.editor-styles-wrapper :where(.wp-site-blocks) > :first-child:first-child {
margin-block-start: 0;
}

.editor-styles-wrapper :where(.wp-site-blocks) > :last-child:last-child {
margin-block-end: 0;
}

.editor-styles-wrapper {
--wp--style--block-gap: 1.5rem;
}

.editor-styles-wrapper :where(body .is-layout-flow)  > * {
margin-block-start: 0;
margin-block-end: 0;
}

.editor-styles-wrapper :where(body .is-layout-flow)  > * + * {
margin-block-end: 0;
margin-block-start: 1.5rem;
}

.editor-styles-wrapper :where(body .is-layout-flow)  > * {
margin-block-start: 1.5rem;
margin-block-end: 0;
}

.editor-styles-wrapper :where(body .is-layout-constrained)  > * {
margin-block-start: 0;
margin-block-end: 0;
}

.editor-styles-wrapper :where(body .is-layout-constrained)  > * + * {
margin-block-end: 0;
margin-block-start: 1.5rem;
}

.editor-styles-wrapper :where(body .is-layout-constrained)  > * {
margin-block-start: 1.5rem;
margin-block-end: 0;
}

.editor-styles-wrapper :where(body .is-layout-flex) {
gap: 1.5rem;
}

.editor-styles-wrapper :where(body .is-layout-grid) {
gap: 1.5rem;
}

.editor-styles-wrapper .is-layout-flow > .alignleft {
float: left;
margin-inline-start: 0;
margin-inline-end: 2em;
}

.editor-styles-wrapper .is-layout-flow > .alignright {
float: right;
margin-inline-start: 2em;
margin-inline-end: 0;
}

.editor-styles-wrapper .is-layout-flow > .aligncenter {
margin-left: auto !important;
margin-right: auto !important;
}

.editor-styles-wrapper .is-layout-constrained > .alignleft {
float: left;
margin-inline-start: 0;
margin-inline-end: 2em;
}

.editor-styles-wrapper .is-layout-constrained > .alignright {
float: right;
margin-inline-start: 2em;
margin-inline-end: 0;
}

.editor-styles-wrapper .is-layout-constrained > .aligncenter {
margin-left: auto !important;
margin-right: auto !important;
}

.editor-styles-wrapper .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
max-width: var(--wp--style--global--content-size);
margin-left: auto !important;
margin-right: auto !important;
}

.editor-styles-wrapper .is-layout-constrained > .alignwide {
max-width: var(--wp--style--global--wide-size);
}

.editor-styles-wrapper .is-layout-flex {
display: flex;
}

.editor-styles-wrapper .is-layout-flex {
flex-wrap: wrap;
align-items: center;
}

.editor-styles-wrapper .is-layout-flex > * {
margin: 0;
}

.editor-styles-wrapper .is-layout-grid {
display: grid;
}

.editor-styles-wrapper .is-layout-grid > * {
margin: 0;
}

.editor-styles-wrapper {
background-color: var(--wp--preset--color--base);
color: var(--wp--preset--color--contrast);
font-family: var(--wp--preset--font-family--crimson-pro);
font-size: var(--wp--preset--font-size--medium);
line-height: 1.6;
--wp--style--root--padding-top: var(--wp--preset--spacing--40);
--wp--style--root--padding-right: var(--wp--preset--spacing--30);
--wp--style--root--padding-bottom: var(--wp--preset--spacing--40);
--wp--style--root--padding-left: var(--wp--preset--spacing--30);
}

.editor-styles-wrapper a:where(:not(.wp-element-button)) {
color: var(--wp--preset--color--contrast);
text-decoration: underline;
}

.editor-styles-wrapper a:where(:not(.wp-element-button)):hover {
text-decoration: none;
}

.editor-styles-wrapper a:where(:not(.wp-element-button)):focus {
text-decoration: underline dotted;
}

.editor-styles-wrapper a:where(:not(.wp-element-button)):active {
color: var(--wp--preset--color--secondary);
text-decoration: underline dotted;
}

.editor-styles-wrapper h1,
.editor-styles-wrapper h2,
.editor-styles-wrapper h3,
.editor-styles-wrapper h4,
.editor-styles-wrapper h5,
.editor-styles-wrapper h6 {
font-weight: 400;
line-height: 1.4;
}

.editor-styles-wrapper h1 {
font-size: clamp(2.032rem, 2.032rem + ((1vw - 0.2rem) * 1.991), 3.625rem);
line-height: 1.2;
}

.editor-styles-wrapper h2 {
font-size: clamp(2.625rem, calc(2.625rem + ((1vw - 0.48rem) * 8.4135)), 3.25rem);
line-height: 1.2;
}

.editor-styles-wrapper h3 {
font-size: var(--wp--preset--font-size--x-large);
}

.editor-styles-wrapper h4 {
font-size: var(--wp--preset--font-size--large);
}

.editor-styles-wrapper h5 {
font-size: var(--wp--preset--font-size--medium);
font-weight: 700;
text-transform: uppercase;
}

.editor-styles-wrapper h6 {
font-size: var(--wp--preset--font-size--medium);
text-transform: uppercase;
}

.editor-styles-wrapper .wp-element-button,
.editor-styles-wrapper .wp-block-button__link {
background-color: var(--wp--preset--color--contrast);
border-radius: 0;
border-color: var(--wp--preset--color--contrast);
border-width: 2px;
border-style: solid;
color: var(--wp--preset--color--base);
font-family: inherit;
font-size: inherit;
line-height: inherit;
padding-top: .667em;
padding-right: 1.333em;
padding-bottom: .667em;
padding-left: 1.333em;
text-decoration: none;
}

.editor-styles-wrapper .wp-element-button:visited,
.editor-styles-wrapper .wp-block-button__link:visited {
color: var(--wp--preset--color--base);
}

.editor-styles-wrapper .wp-element-button:hover,
.editor-styles-wrapper .wp-block-button__link:hover {
background-color: var(--wp--preset--color--base);
border-color: var(--wp--preset--color--contrast);
border-width: 2px;
border-style: solid;
color: var(--wp--preset--color--contrast);
}

.editor-styles-wrapper .wp-element-button:focus,
.editor-styles-wrapper .wp-block-button__link:focus {
background-color: var(--wp--preset--color--contrast);
color: var(--wp--preset--color--base);
text-decoration: underline dotted;
}

.editor-styles-wrapper .wp-element-button:active,
.editor-styles-wrapper .wp-block-button__link:active {
background-color: var(--wp--preset--color--secondary);
color: var(--wp--preset--color--base);
text-decoration: underline dotted;
}

.editor-styles-wrapper .wp-block-pullquote {
border-width: 1px 0;
border-style: solid;
font-size: clamp(0.984em, 0.984rem + ((1vw - 0.2em) * 0.645), 1.5em);
line-height: 1.3;
margin-top: var(--wp--preset--spacing--40) !important;
margin-bottom: var(--wp--preset--spacing--40) !important;
}

.editor-styles-wrapper .wp-block-pullquote cite {
font-size: var(--wp--preset--font-size--small);
font-style: normal;
text-transform: none;
}

.editor-styles-wrapper .wp-block-navigation {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-navigation a:where(:not(.wp-element-button)) {
color: inherit;
text-decoration: none;
}

.editor-styles-wrapper .wp-block-navigation a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-navigation a:where(:not(.wp-element-button)):focus {
text-decoration: underline dashed;
}

.editor-styles-wrapper .wp-block-navigation a:where(:not(.wp-element-button)):active {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-button .wp-block-button__link {
border-radius: 2px;
}

.editor-styles-wrapper .wp-block-comment-author-name a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-comment-author-name a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-comment-author-name a:where(:not(.wp-element-button)):focus {
text-decoration: underline dashed;
}

.editor-styles-wrapper .wp-block-comment-author-name a:where(:not(.wp-element-button)):active {
color: var(--wp--preset--color--secondary);
text-decoration: none;
}

.editor-styles-wrapper .wp-block-comment-date {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-comment-date a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-comment-date a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-comment-date a:where(:not(.wp-element-button)):focus {
text-decoration: underline dashed;
}

.editor-styles-wrapper .wp-block-comment-date a:where(:not(.wp-element-button)):active {
color: var(--wp--preset--color--secondary);
text-decoration: none;
}

.editor-styles-wrapper .wp-block-comment-edit-link {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-comment-reply-link {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-comments-pagination {
margin-top: var(--wp--preset--spacing--40);
}

.editor-styles-wrapper .wp-block-comments-pagination a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-comments-title {
font-size: var(--wp--preset--font-size--large);
margin-bottom: var(--wp--preset--spacing--40);
}

.editor-styles-wrapper .wp-block-heading {
margin-top: var(--wp--preset--spacing--60);
margin-right: var(--wp--preset--spacing--60);
margin-bottom: var(--wp--preset--spacing--60);
margin-left: var(--wp--preset--spacing--60);
}

.editor-styles-wrapper .wp-block-image img,
.editor-styles-wrapper .wp-block-image .wp-block-image__crop-area,
.editor-styles-wrapper .wp-block-image .components-placeholder {
border-radius: 2px;
}

.editor-styles-wrapper .wp-block-post-author {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-post-content a:where(:not(.wp-element-button)) {
color: var(--wp--preset--color--secondary);
}

.editor-styles-wrapper .wp-block-post-date {
font-size: var(--wp--preset--font-size--small);
font-weight: 400;
}

.editor-styles-wrapper .wp-block-post-date a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-post-date a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-post-excerpt {
font-size: var(--wp--preset--font-size--medium);
}

.editor-styles-wrapper .wp-block-post-featured-image img,
.editor-styles-wrapper .wp-block-post-featured-image .block-editor-media-placeholder,
.editor-styles-wrapper .wp-block-post-featured-image .wp-block-post-featured-image__overlay {
border-top-left-radius: 40px;
border-top-right-radius: 40px;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}

.editor-styles-wrapper .wp-block-post-terms {
font-size: var(--wp--preset--font-size--small);
}

.editor-styles-wrapper .wp-block-post-title {
font-weight: 400;
margin-top: 1.25rem;
margin-bottom: 1.25rem;
}

.editor-styles-wrapper .wp-block-post-title a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-post-title a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-post-title a:where(:not(.wp-element-button)):focus {
text-decoration: underline dashed;
}

.editor-styles-wrapper .wp-block-post-title a:where(:not(.wp-element-button)):active {
color: var(--wp--preset--color--secondary);
text-decoration: none;
}

.editor-styles-wrapper .wp-block-query h2 {
font-size: var(--wp--preset--font-size--x-large);
}

.editor-styles-wrapper .wp-block-query-pagination {
font-size: var(--wp--preset--font-size--small);
font-weight: 400;
}

.editor-styles-wrapper .wp-block-query-pagination a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-query-pagination a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-quote {
border-width: 1px;
padding-right: var(--wp--preset--spacing--30);
padding-left: var(--wp--preset--spacing--30);
}

.editor-styles-wrapper .wp-block-quote cite {
font-size: var(--wp--preset--font-size--small);
font-style: normal;
}

.editor-styles-wrapper .wp-block-site-title {
font-size: var(--wp--preset--font-size--medium);
font-weight: normal;
line-height: 1.4;
}

.editor-styles-wrapper .wp-block-site-title a:where(:not(.wp-element-button)) {
text-decoration: none;
}

.editor-styles-wrapper .wp-block-site-title a:where(:not(.wp-element-button)):hover {
text-decoration: underline;
}

.editor-styles-wrapper .wp-block-site-title a:where(:not(.wp-element-button)):focus {
text-decoration: underline dashed;
}

.editor-styles-wrapper .wp-block-site-title a:where(:not(.wp-element-button)):active {
color: var(--wp--preset--color--secondary);
text-decoration: none;
}</style>

@tellthemachines
Copy link
Contributor

Interesting. From the output, it looks like the logic for style generation in the theme.json class is up to date, but the definitions coming from the core theme.json file are from a previous version. If that's the case though, I don't understand why there are 3 rules for flow layout instead of 2:

   .editor-styles-wrapper :where(body .is-layout-flow)  > * {
    margin-block-start: 0;
    margin-block-end: 0;
    }
    
    .editor-styles-wrapper :where(body .is-layout-flow)  > * + * {
    margin-block-end: 0;
    margin-block-start: 1.5rem;
    }
    
    .editor-styles-wrapper :where(body .is-layout-flow)  > * {
    margin-block-start: 1.5rem;
    margin-block-end: 0;
    }

Could your dev env by any chance be running on an older WP version? The caching issue from #45713 should have been fixed in 6.2.

@jasmussen
Copy link
Contributor Author

jasmussen commented Apr 26, 2023

Here's a screenshot of my updates page, I should be on a clean 6.2:

Screenshot 2023-04-26 at 09 13 15

I'm running the trunk GB plugin, and using Local to run the environment. In case it helps, here's the theme I'm using, which is built using the site editor and Create Block Theme, from a TT3 base:

verso-variant.zip

Edit: I'm also happy to beta test nightly WordPress variants if that's helpful. I can update to latest nightly, just let me know.

@tellthemachines
Copy link
Contributor

Oooooh I see, the culprit is that theme's theme.json file. It has a definitions object inside settings > layout that is overriding the definitions from the core theme.json file. Removing those definitions should make everything work correctly! It shouldn't be necessary to redefine them in a theme anyway, unless you're looking to override the core layout functionality.

@jasmussen
Copy link
Contributor Author

Interesting, so it seems the issue here is either from the theme, or from Create Block Theme, as at no point have I manually edited the theme.json. @matiasbenedetto would you be able to look at this and see where it might come from?

Here's the pertinent bit:

			"definitions": {
				"constrained": {
					"baseStyles": [
						{
							"rules": {
								"float": "left",
								"margin-inline-end": "2em",
								"margin-inline-start": "0"
							},
							"selector": " > .alignleft"
						},
						{
							"rules": {
								"float": "right",
								"margin-inline-end": "0",
								"margin-inline-start": "2em"
							},
							"selector": " > .alignright"
						},
						{
							"rules": {
								"margin-left": "auto !important",
								"margin-right": "auto !important"
							},
							"selector": " > .aligncenter"
						},
						{
							"rules": {
								"margin-left": "auto !important",
								"margin-right": "auto !important",
								"max-width": "var(--wp--style--global--content-size)"
							},
							"selector": " > :where(:not(.alignleft):not(.alignright):not(.alignfull))"
						},
						{
							"rules": {
								"max-width": "var(--wp--style--global--wide-size)"
							},
							"selector": " > .alignwide"
						}
					],
					"className": "is-layout-constrained",
					"name": "constrained",
					"slug": "constrained",
					"spacingStyles": [
						{
							"rules": {
								"margin-block-end": "0",
								"margin-block-start": "0"
							},
							"selector": " > *"
						},
						{
							"rules": {
								"margin-block-end": "0",
								"margin-block-start": null
							},
							"selector": " > * + *"
						}
					]
				},

It scares me a little that those definitions exist, and are actively causing a regression since they are overriding the core block styles. I'm lacking some of the technical foundations, but what is the role of these definitions? And why might a theme want to add them?

Thanks so much for the help debugging!

@mikachan
Copy link
Member

mikachan commented Apr 27, 2023

I believe these layout definitions are from the Gutenberg default theme.json, which Create Block Theme will use unless they are overwritten when the sources are merged (default, theme, user).

There's an open issue here with a bit more discussion: WordPress/create-block-theme#324.

@jasmussen
Copy link
Contributor Author

Seems like we want to omit those from the theme itself, otherwise it can't inherit them from Gutenberg, with the bugfixes we might make to the block editor in tow.

@tellthemachines
Copy link
Contributor

Seems like we want to omit those from the theme itself, otherwise it can't inherit them from Gutenberg, with the bugfixes we might make to the block editor in tow.

Yes, the definitions should only ever be in the core theme.json, as they are used to build the core styles for each layout type. They shouldn't be in theme files at all.

Are we good to close this issue now?

@jasmussen
Copy link
Contributor Author

Are we good to close this issue now?

Yes! Thank you for all the debugging help, it went above and beyond.

@djmalibiran
Copy link

Just sharing the following just in case some people encounter the same problem.
If the settings.spacing.blockGap is set to true , you need to set styles.spacing.blockGap to "0" .

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 [Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants