-
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
Fix: Cover Block: Unnecessary default styles for H2 heading #17815
Fix: Cover Block: Unnecessary default styles for H2 heading #17815
Conversation
@@ -150,3 +116,42 @@ | |||
z-index: z-index(".wp-block-cover__video-background"); | |||
object-fit: cover; | |||
} | |||
|
|||
// Styles bellow only exist to support older versions of the block. |
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.
Can we expand a little bit on the differences compared to the current markup and how we're using them to target only the previous versions?
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.
I explained that on the description of the PR, but I agree that it should be in the comment I added it.
Is there a policy for how long we keep deprecated code? I might be wrong but if I remember correctly, |
2ac86e4
to
9cc942d
Compare
WordPress tries to always be back-compatible so it seems core needs to always contain the styles that made a previous version of the blocks work.
I created a test site with WordPress 5.0 and verified h2 was not used in the cover. I guess in this case we can remove the h2 selectors to save some bytes. Any thoughts on this @youknowriad? |
I think we should keep them for now until we figure a better strategy. That's not the only place where we support plugin only markup. We have several blocks in that case and we even have hidden blocks that were entirely deprecated. |
Thank you for your insights @youknowriad I guess in this case the PR should be ready. |
padding: $block-padding; | ||
text-align: center; | ||
} | ||
|
||
h2:not(.has-text-color), |
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.
Do we need this here?
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.
Yes, we need these styles because of the previous versions, they were always white. Current versions inriht the color, I move these styles to the deprecated zone.
9cc942d
to
a0e712a
Compare
a0e712a
to
c73f4b5
Compare
Description
Fixes: #17704
The cover block needs h2 styles to support older versions of the block, but these styles were styling current heading blocks and make the ability of themes styling the block hard.
This PR fixes this problem by changing the heading selector to rely on section.wp-block-cover-image as a parent. Versions that not had inner blocks and used an h2 heading had a section (and not a div as the current) with a class wp-block-cover-image (and not a wp-block-cover as the current). So relying on this we can apply the styles to older versions and not affect new versions.
Styles that only exist to support deprecated versions were moved and grouped together.
How has this been tested?
I used the classic editor and created a post with the following content (pasting it on Gutenberg automatically migrates to the new version of the blocks):
I disabled classic editor, opened the post verified it was automatically migrated. Did not save the migration.
I opened the post with Gutenberg master and in this branch and verified it displays equal in both places.
I created a new cover block, I added a new heading inside the cover and verified it was not centered aligned.