-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CSS Priority Changes in Non-iframe Editor For WP 6.6 #63688
Comments
Thanks for taking the time to write up this detailed issue @shodoi 👍 I can replicate the issue using WP 6.6. The root cause of the divergence between the iframed and non-iframed editors is a known bug where top-level element styles in theme.json had their specificity unintentionally increased. This issue was fixed via #63403 and was included in yesterday's Gutenberg 18.8 release. It will be included in the WP 6.6.1 point release which should be available in the coming days. You can read more in this ticket. With Gutenberg 18.8 active, this is what I get comparing the two editors states:
|
Thank you for your comment, @aaronrobertshaw I was able to reproduce the screenshot you provided with Gutenberg 18.8.0 enabled. I believe the {
"styles": {
"elements": {
"h2": {
"spacing": {
"margin": {
"top": "6.5rem"
}
}
}
},
"spacing": {
"blockGap": "1.4rem"
}
}
} The Iframed .is-layout-constrained > * {
margin-block-start: 1.4rem;
margin-block-end: 0;
}
h2 {
font-size: var(--wp--preset--font-size--x-large);
margin-top: 6.5rem; // not working
} Non-iframe .editor-styles-wrapper .is-layout-constrained > * {
margin-block-start: 1.4rem;
margin-block-end: 0;
}
.editor-style-wrapper h2 {
font-size: var(--wp--preset--font-size--x-large);
margin-top: 6.5rem; // not working
} Up until WordPress 6.5.5, h2 {
font-size: var(--wp--preset--font-size--x-large);
margin-top: 6.5rem; // working
}
:where(body .is-layout-constrained) > * {
margin-block-start: 1.4rem;
margin-block-end: 0;
} |
That is correct. I altered the values you had just to make it easier to confirm the correct values and they weren't defaults etc.
To my understanding, yes, it is the correct behaviour. The general thinking I have is that:
I've also discussed this with @andrewserong, who did a lot of the hard work in developing the block gap feature initially (🙇) and I think we're on the same page. Certainly happy to hear any alternative opinions of course.
There was a point in the Gutenberg plugin where the layout styles were temporarily reduced to zero-specificity i.e. being wrapped in |
WordPress 6.5.5 By default :where() wraps, but that was not the correct behavior.
The above CSS is WordPress 6.5.5 default only, Gutenberg is inactive. If you enable WordPress 6.5.5 and Gutenberg 18.8.0, it will look like the screenshot.
|
Thanks for helping to work through this issue @shodoi, I appreciate it 👍 I can confirm what you reported in terms of selectors for 6.5. They were also consistent across iframed/non-iframed editors and the frontend. When it comes to the expected behaviour, the more I've looked at this the more I lean toward what was outlined above:
I'm happy to hear the thoughts of others but I'm leaning towards not making any further changes to these selectors. The current state in GB 18.8, and in 6.6.1 (when it is released), will be consistent across the editors and frontend as well as match the correct behaviour. Let's leave this issue open for a while longer to allow others the opportunity to weigh in. |
I agree with the above outline, I think it makes good conceptual sense for how these different pieces fit together 👍 |
Thank you for your response, @aaronrobertshaw @andrewserong . I understand that the behavior in WordPress 6.6 and Gutenberg 18.8 is correct. a. Specifying null for
b. Specifying margin for the heading block (not the heading element)
I was expecting the following to work, but it seems it's not being applied...
|
I believe the reason this doesn't work is; that theme.json config would target a nested, or inner, Given you shouldn't nest heading elements, I'd recommend using either of the other options you listed, most likely option B. |
Description
When specifying
styles.elements.h2.spacing.margin.top
in theme.json, I expected the same appearance in both iframe Editor and Non-iframe Editor, but the styles differ.In the iframe Editor,
margin-top: 5rem
is applied toh2
as expected.In the Non-iframe Editor, the value of
styles.spacing.blockGap
takes precedence, overriding themargin-top
ofh2
.Step-by-step reproduction instructions
styles.elements.h2.spacing.margin.top
to theme.jsonScreenshots, screen recording, code snippet
iframe Editor
Non iframe Editor
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: