-
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
Quote: Prevent block theme styles overriding global border and padding #64045
Conversation
Size Change: +34 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
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 tested it using Emptytheme. I confirmed that the theme style can be overridden correctly from the global styles, but I found that there are cases where it is not overridden correctly in block instances. That is, when only the border width is applied.
After investigating, I found that if only the border width is applied in the global styles, the border-style: solid
is also applied at the same time, so it overrides the theme style border:none
:
On the other hand, in block instances, it seems that the border is overridden by the theme's border:none
, probably because only the border-width
is applied as an inline style:
This can be solved by explicitly applying border-style
to the block instance, but is there a way to solve it without doing this?
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
To solve this problem, I think it might be effective to add the following CSS to the .wp-block-quote {
&:where([style*="border-width"]) {
border-style: solid;
}
} |
Thanks for the review @t-hamano 👍
The I'm in two minds on this one. I don't think adding more and more fallback CSS is a good option. The An alternative path that can be explored as a follow-up is to check the now available global styles data and apply the same fallback border-style logic for the block instances if that's what we ultimately want. This would be a more holistic approach that can be leveraged across all blocks that adopt border supports. One last thing, the proposed CSS tweak would need to be extended for all longhand So after having typed all that out. I propose we proceed with this PR as is. Depending on what comes of the work around displaying inherited global styles in the block inspector, we can follow up on the fallback for borders then. What do you think? |
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.
Thank you for the detailed explanation!
If I'm explaining it correctly, then it's fine to ship this PR first, right?
Depending on what comes of the work around displaying inherited global styles in the block inspector, we can follow up on the fallback for borders then.
I discovered that in #37752, it's being considered to reflect global style values in the block inspector. Border fallbacks might also be considered in this issue.
Looking at the conversation, and testing the PR, it solves the main issue. I'll merge while @aaronrobertshaw is away.
|
Addresses: #63544 (comment)
What?
Fixes an issue where the Quote block's theme styles have higher specificity than global styles preventing the recently adopted border support styles from applying correctly when the quote block is center or right-aligned.
This fix now also allows global styles padding for the quote block to apply as expected when the block is aligned.
Why?
Provides the expected styling behaviour for the Quote block.
How?
:where
so the resulting selector has0-1-0
specificity to match global stylesTesting Instructions
Screenshots or screencast