Heading: Update the order of style nodes for correct css specificity #40819
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.
What?
This PR fixes following two issues.
When values are provided in both
styles.blocks.core/heading
andstyles.elements.h1
the values provided in the "blocks.core/heading" portion are leveraged rather than the "elements.h1" section.Also
styles.blocks.core/heading.elements.h1
producesh1 h1
selector instead ofh1
, because of this overrides are not working.Fixes: #39698
Why?
Use case would be user can define generic styles such as fontFamily at
core/heading
which would apply to all headings and can defineelements.h6
with a different fontFamily to override.Currently this is not working because of CSS specificity issues (order of the style placement is not right)
How?
Changed the order of blocks and elements so that result styles are in right overriding order.
Given theme.json definition
Following is the result.
Testing Instructions
Case 1:
Define styles under
styles.blocks.core/heading
and override them instyles.elements.h1
.Later styles should apply in frontend.
Case 2:
Define styles under
styles.blocks.core/heading
and override them instyles.blocks.core/heading.element.h1
Later styles should apply in frontend.
Screenshots or screencast