-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove CSS that causes conflict with theme.json #36424
Conversation
Thank you for the PR! Thanks for the ping! So, here's what's up. For non-block themes, we have a blanket rule that outputs top and bottom margins for everything that's defined to be a block — in the editor only. This rule:
The problem here is, what is defined as a "block" is pretty generic, and includes both the columns block, and the column block. And so if we remove the rule as this PR does, the following happens in TT1: It's fine in a block theme, because there aren't those pre-existing margins applied in the editor: And so if we remove this rule, classic themes that use columns will look different in the editor. So I think we need a different fix: keep the rule in the editor.scss file, so that it applies only to the editor, but lower specificity. For example, this rule:
Without testing theme.json, this should have low enough specificity that anything you add there should override it. I consider this For me it works *:
|
Ahh I see. Thanks for the additional information. I have added your recommended CSS and it works well with theme.json configured margins. I also tested in TT1 and removed the blanket Anyway, this should be good to go unless you have any further concerns. Thanks for reviewing! |
Thanks for the fix, kudos on the extra comment. Codewise this looks good and should work well. I don't have the bandwidth to test this one right now, but things to verify is to smoke test a few classic themes. A way to test would be a 2 columns block with paragraphs inside, then paragraphs before and after. This PR should look the same as trunk — with the notable exception of TT1 which has that rule I mentioned. |
I have gone ahead and tested with Twenty Twenty-One, Twenty Twenty, and Twenty Nineteen as well as TT1 Blocks, and TT2 with custom margins in theme.json. All works as expected. |
I've restarted the tests as the failure seems unrelated. If someone else is able to give this one a quick sanity chec, the code should be good to go. |
Hi, @ndiego Can you rebase this branch on top of the trunk? Failing E2E is skipped for now, so this should fix the checks. |
Now that theme.json supports margin for column blocks, the removed CSS takes precedent over any configured theme.json margin styles. This impedes theme.json adoption. Since this CSS served no real purpose anyway, I propose that it is removed.
@Mamaduka just rebased. Let me know if this needs anything else and hopefully the checks all pass 🤞 |
@Mamaduka and @jasmussen I have retested this and it's still good to go. Anyway we can get this fix merged? |
Sorry for missing this. It's in bug territory so it can still land. I'll give this one a spin again tomorrow and see if I can't green light it, if no-one else beats me to it. Thanks for your work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I gave it a thorough test.
To recap, the problem to solve is that in classic themes, a blanket top/bottom margin is output on every block, including column (singular). Those rules are not output in pure block themes, but are in classic themes. In that light, this PR solves a problem for classic themes that use theme.json.
Block theme test first — and in this case there should be no difference to trunk:
All works, and the code takes even if it doesn't unset anything. The use of :where means low specificity.
The rule does take effect:
Here's what it looks like without the rule:
Note that I had to rebase to test this PR. This is good to land. My only question is, should we add a small additional comment to note that this rule is meant for classic themes that use theme.json, and isn't needed (but is harmless) for block themes?
Pre-approving, but would love that small comment added, then you can land this. Thanks again!
Merging this as it has the backport label and I see that it's approved. |
* Remove CSS that causes conflict with theme.json Now that theme.json supports margin for column blocks, the removed CSS takes precedent over any configured theme.json margin styles. This impedes theme.json adoption. Since this CSS served no real purpose anyway, I propose that it is removed. * Add back styling but with lower specificity. * Fix linting errors.
Thanks @noisysocks, and thanks @jasmussen for the additional review. I tested again just now and all looks good. |
Description
Now that theme.json supports margin for column blocks, the removed CSS takes precedent over any configured theme.json margin styles. This impedes theme.json adoption. Since this CSS served no real purpose anyway, I propose that it is removed.
How has this been tested?
This has been tested with TT1 blocks, TT2 and custom FSE themes and Gutenberg 11.9.
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).