-
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
Try: Increase specificity of horizontal block margins. #30337
Conversation
How to test:
|
Size Change: +127 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
Ack yes. This seems unsustainable. Right now we have this rule. Before we had this:
that rule was troublesome enough (see #28878), but some of the block margin rule specificity was adapted to that. Now the rule is this, effectively:
that's pretty high specificity, which means every theme or block that mitigated that rule needs higher specificity. Is there any way we can remove that margin rule? The issue is the same for the alignments inside, but those rules are better scoped and less intrusive. In absence of removing those margin rules, can we reduce their specificity? CC: @youknowriad |
I don't know, it's only useful for themes without theme.json files, so I'm not sure how we can still have the rule but only for these themes. |
I'm happy to be able to close this one in favor of #30375 which is a better solution. I'd be grateful if you could help test and land that one! |
Description
A recent PR scoped the automatic left and right margins for
.wp-block
to themes that do not support layout. This is great because those left/right margins wreak havoc. See #29335.However in doing so, the
:not
selector ended up adding specificity to the rule. That means theme rules that try to override those rules now fail in doing so. I don't know any good solution to this problem, other than adding additional specificity for those rules.It also had the side-effect of adding auto margins for some block styles. Specifically, it centered blocks inside flex containers, like Social Links, Navigation, and Buttons (auto margins in flex containers usually results in centered or space-between like layouts):
This PR fixes that by escalating the specificity for those blocks:
Finally, the higher specificity margin rules hid a bug in TwentyTwentyOne, where a blanket top-margin rule would cause a staircase effect on the Buttons block. Before this PR (note, the buttons block does not have space-between applied):
After this PR:
Note that the space-between effect has been fixed, and theme margins now affect the block. But they just affect the buttons block wrongly by targetting first-child and last-child rules, assuming they are in a vertical sequence:
TwentyTwenty does not have this problem:
Checklist:
*.native.js
files for terms that need renaming or removal).