Heading: Fix per-level element style overrides#49189
Closed
aaronrobertshaw wants to merge 1 commit into
Closed
Conversation
886d796 to
6a92764
Compare
|
Flaky tests detected in 6a92764. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4464511878
|
Mamaduka
reviewed
Mar 20, 2023
Member
Mamaduka
left a comment
There was a problem hiding this comment.
Thank you, @aaronrobertshaw!
Can you add a simple PHPUnit test for this particular case? We can confirm that the snippet from the DevNote produces desired CSS.
Contributor
Author
|
Closing this PR as per #49070 (comment).
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #49070
What?
Corrects the CSS selector used for generating h1-h6 element style overrides for the Heading block.
Why?
Without the correct selectors a theme author can't override the Heading block styles per level.
How?
As the heading elements are a special edge case, this quick fix adds a conditional to the generation of element selectors during the theme.json block metadata processing. If the element in question is
h1-h6it will prepend the element selector to the block selector instead of appending the element as a child to the block selector.Testing Instructions
h1-h6element style, then update thecore/headingblock styles to include an override for a specifich1-h6element style.Theme.json Snippet
{ "styles": { "elements": { "h1": { "color": { "background": "blue" } } }, "blocks": { "core/heading": { "elements": { "h1": { "color": { "background": "pink" } }, "h3": { "color": { "background": "aliceblue" } }, "h5": { "color": { "background": "darkseagreen" } } } } } } }Example block markup
Screenshots or screencast