Reduce unnecessary selector specificity for Button block #23246
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
See #23222 (comment).
The selector used is unnecessarily specific (0,3,0) and it only needs to be (0,2,0) to override the block default margins since it's enqueued after and thus take location precedence.
I'd still leave the comment about it being specific since ideally it would be just
.wp-block-button
but it cant because of the block default margin selector (which in turn is there to override list margin-left properties.There's some minor spacing difference between the buttons in editor and frontend but that's shown in master already and is unrelated to this.
One real world reason I'd argue this is needed is because it's much more common for themers use to
.wp-block-buttons .wp-block-button
than it would be for them to even know you can chain selectors like.wp-block-buttons .wp-block-button.wp-block-button
. So to override it we'd probably see lots of.entry-content .wp-block-buttons .wp-block-button
.How has this been tested?
Tested adding buttons in twentynineteen and twentytwenty
Screenshots
Twentytwenty Editor:
TwentyTwenty Frontend:
TwentyNinteen Editor:
TwentyNineteen Frontend:
Types of changes
Checklist: