Fix bump in specificity for layout styles in non-iframed editor#7145
Fix bump in specificity for layout styles in non-iframed editor#7145talldan wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for putting this together @talldan 👍
I've tested it in the post editor, following the instructions on this PR and the additional steps outlined over on the Gutenberg PR in WordPress/gutenberg#64076 (comment).
✅ Block-level margin styles in global styles overrides base spacing styles
✅ Block-level margin styles in global styles overrides block level spacing in global styles (e.g. Group block set to 0 block spacing will be overridden by paragraphs within the Group if paragraphs have margin set)
✅ Block instance level block spacing overrides global styles margin rules
✅ Block instance level margins override block instance level block spacing
✅ Block spacing for buttons, social icons, row, stack, and grid all appear to be working
I didn't spot any issues. This LGTM 🚢
| Before (iframed) | Before (non-iframed) |
|---|---|
![]() |
![]() |
| After (iframed) | After (non-iframed) |
|---|---|
![]() |
![]() |
hellofromtonya
left a comment
There was a problem hiding this comment.
- ✅ Resolves the issue - See my test report.
- ✅ Correctly generates the expected CSS - See my findings report.
- ✅ Changes match changes in Gutenberg PR.
LGTM and ready for commit.
|
Committed to |




Trac ticket: https://core.trac.wordpress.org/ticket/61829
Github PR: WordPress/gutenberg#64076
Backports the changes from WordPress/gutenberg#64076
What?
Fixes the issue mentioned in WordPress/gutenberg#53468 (comment) to restore theme.json spacing rules taking precedence over the implicit spacing rules in a non-iframed editor.
How?
In
trunkthe code generates a selector like.is-layout-flow > *(specificity 0,1,0) which is fine normally. When in a non-iframed editor, thetransformStylesfunction prefixes selectors with.editor-styles-wrapperto scope them to the editor canvas, so it becomes.editor-styles-wrapper .is-layout-flow > *(specificity 0,2,0), a bump in specificity that causes the precedence of styles to change.In this PR I've changed the selector to
:root :where(.is-layout-flow) > *(still specificity 0,1,0).transformStyleshandles 'root' selectors a little differently, it'll instead replace the:rootpart so it becomes.editor-styles-wrapper where(.is-layout-flow) > *(keeping the specificity at 0,1,0).The other layout selector that this affects is the
:first-child:last-childselectors that are responsible for resetting margin at the start and end of a block list. They traditionally have a 0,2,0 specificity so that they can override both the above rule and any rules in the theme.json. Those selectors are also maintained at 0,2,0 with this change, they become something like:root :where(.is-layout-flow) > :first-child.Here's a list of selectors that will be updated (according to our php tests)
Testing Instructions
styles.blocks):4remtop/bottom margin.Also worth checking out
trunkand comparing the styles. You should see that in trunk the iframed editor looks correct, but when you activate custom fields the non-iframed editor styles are broken.Screenshots or screencast
Before
After
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.