Block Supports: Fix custom CSS cascade order against block style variations#12551
Block Supports: Fix custom CSS cascade order against block style variations#12551ramonjd wants to merge 1 commit into
Conversation
…ations. Make per-block custom CSS reliably win over block style variation styles by declaring `block-style-variation-styles` as a dependency of the `wp-block-custom-css` style handle. Without this explicit dependency the order was decided by enqueue order, and custom CSS could lose to variation styles at equal specificity. The `block-style-variation-styles` handle is registered on demand if it doesn't exist yet, because a style with an unregistered dependency is never printed. Backport of WordPress/gutenberg#80340. Props andrewserong, ramonopoly. Fixes #65641. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I'm not sure about this one, at least the front end fix. I think I'm going after the symptom and not the virus 😄. I think maybe custom CSS needs special handling not variations. Not sure |
|
Closing this as not needed right now. |
Trac ticket: https://core.trac.wordpress.org/ticket/65641
Description
Backport of WordPress/gutenberg#80340.
Makes per-block custom CSS reliably win over block style variation (section style) styles on the front end. Both rulesets are wrapped in
:root :where()and print at 0-1-0 specificity, so whichever prints later wins. That order was accidental: it fell out of enqueue order between thewp-block-custom-cssandblock-style-variation-styleshandles.Changes
wp-block-custom-cssnow declaresblock-style-variation-stylesas a dependency, so custom CSS always prints after variation styles.Testing
background-color: blue;.