Skip to content

Fix block library and global styles stylesheet ordering when a block style variation is active - #63918

Merged
talldan merged 3 commits into
trunkfrom
fix/stylesheet-ordering
Jul 25, 2024
Merged

talldan merged 3 commits into
trunkfrom
fix/stylesheet-ordering

Conversation

@talldan

@talldan talldan commented Jul 25, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #63912

Core backport: WordPress/wordpress-develop#7088
Trac Ticket: https://core.trac.wordpress.org/ticket/61748

What?

Reorders the dependencies for block-style-variations-styles

Why?

The order of the dependencies here was causing different ordering of stylesheets on the page

When a theme is using theme.json presets that match the naming used by core, this can suddenly cause those core styles to override those from the theme.json (the css variables from core take precedence over those generated from the theme.json.

Props to @aaronrobertshaw for spotting the problematic line of code

Testing Instructions

  • Alter the Twenty Twenty Four theme.json file to include a font size with the slug normal that is something fairly large, like 2rem
  • Make a page with some text using that font size and preview it - note that the text is correctly sized to 2rem
  • Add a button with the Outline style on the same page and preview it again

Expected: the text is still 2rem
Before: the text was incorrectly 16px

Screenshots or screencast

Before

Regular button Outline button
Screenshot 2024-07-25 at 10 33 43 AM Screenshot 2024-07-25 at 10 33 32 AM

After

Regular button Outline button
Screenshot 2024-07-25 at 10 33 57 AM Screenshot 2024-07-25 at 10 34 08 AM

@talldan talldan added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jul 25, 2024
@talldan talldan self-assigned this Jul 25, 2024
@talldan
talldan requested a review from spacedmonkey as a code owner July 25, 2024 02:39
@github-actions

github-actions Bot commented Jul 25, 2024 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: eric-michel <ytfeldrawkcab@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ramonjd

ramonjd commented Jul 25, 2024

Copy link
Copy Markdown
Member

Here's what I'm seeing on the frontend. All my elements have the "normal" font size applied, at 3.333rem

Before After
Screenshot 2024-07-25 at 1 07 18 PM Screenshot 2024-07-25 at 1 06 01 PM

All looks fine in the editor before and after.

@andrewserong andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simple fix, good work identifying it @aaronrobertshaw, and thanks for the quick PR @talldan!

This is testing nicely for me and follows the order in which these are registered normally in core, too (outside of block style variations) 👍

Before After
image image

I also quickly smoke tested that custom block style variations are working as expected for me, too (screenshot includes a style variation for paragraph and button blocks):

image

LGTM! 🚀

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Global styles CSS is now taking precedence over the block library common CSS

Before After
Screenshot 2024-07-25 at 1 10 25 PM Screenshot 2024-07-25 at 1 10 45 PM

@aaronrobertshaw aaronrobertshaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well 👍

✅ Could replicate issue
✅ Applying the fix resolves the problem
✅ Fix works regardless of whether core block assets are loaded separately

@talldan talldan added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Jul 25, 2024
@talldan
talldan merged commit ae83155 into trunk Jul 25, 2024
@talldan
talldan deleted the fix/stylesheet-ordering branch July 25, 2024 04:22
@github-actions github-actions Bot added this to the Gutenberg 19.0 milestone Jul 25, 2024
@talldan talldan mentioned this pull request Aug 5, 2024
8 of 12 tasks
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Aug 5, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.



git-svn-id: https://develop.svn.wordpress.org/trunk@58850 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 5, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.


Built from https://develop.svn.wordpress.org/trunk@58850


git-svn-id: http://core.svn.wordpress.org/trunk@58246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions Bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Aug 5, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.


Built from https://develop.svn.wordpress.org/trunk@58850


git-svn-id: https://core.svn.wordpress.org/trunk@58246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@hellofromtonya hellofromtonya removed the Needs PHP backport Needs PHP backport to Core label Aug 7, 2024
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Aug 7, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Reviewed by hellofromTonya.
Merges [58850] to the 6.6 branch.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.

git-svn-id: https://develop.svn.wordpress.org/branches/6.6@58861 602fd350-edb4-49c9-b593-d223f7449a82
@hellofromtonya

Copy link
Copy Markdown
Contributor

Removed the Needs PHP Backport label as the PHP changes were committed into WordPress Core's trunk and backported to WordPress' Core 6.6 branch for 6.6.2.

markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 7, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Reviewed by hellofromTonya.
Merges [58850] to the 6.6 branch.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.
Built from https://develop.svn.wordpress.org/branches/6.6@58861


git-svn-id: http://core.svn.wordpress.org/branches/6.6@58257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@talldan talldan added the Backported to WP Core Pull request that has been successfully merged into WP Core label Aug 8, 2024
talldan added a commit that referenced this pull request Aug 8, 2024
…style variation is active (#63918)

* Fix block library and global styles stylesheet ordering when a block style variation is active

* Add backport changeglog

* Update core backport

----

Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: eric-michel <ytfeldrawkcab@git.wordpress.org>
@talldan

talldan commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

I've cherry picked this to the wp/6.6 branch to keep the code in sync - ae218b7.

@talldan talldan removed the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Aug 8, 2024
aslamdoctor pushed a commit to aslamdoctor/wordpress-develop that referenced this pull request Dec 28, 2024
…pplied.

Adjusts the dependency order to ensure stylesheets are output in the correct order.

Syncs the PHP changes from WordPress/gutenberg#63918.

Props talldanwp, aaronrobertshaw, andrewserong, aristath, mukesh27, ramonopoly, ytfeldrawkcab.
Fixes #61748.



git-svn-id: https://develop.svn.wordpress.org/trunk@58850 602fd350-edb4-49c9-b593-d223f7449a82
t-hamano added a commit that referenced this pull request Jul 13, 2026
…ary styles (#80062)

* Fix custom CSS support reordering global-styles ahead of wp-block-library

Block-level custom CSS registered `wp-block-custom-css` with a dependency
on `global-styles` only, then enqueued it at priority 1. This pulled
`global-styles` ahead of `wp-block-library` in the print order, so block
library fallbacks (e.g. the static `--wp--preset--font-size--*` values in
common.scss) overrode the global styles and broke fluid typography.

List `wp-block-library` before `global-styles` in the dependency array so
block library prints first and global styles keep winning the cascade,
mirroring the block style variations fix in #63918.

Fixes #79974

Co-Authored-By: Claude <noreply@anthropic.com>

* Add backport changelog

* Update docblock

Co-authored-by: Weston Ruter <westonruter@gmail.com>

---------

Unlinked contributors: goutetsuguma.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Projects

No open projects
Status: ✅ Done 6.6.1

Development

Successfully merging this pull request may close these issues.

Setting Button block to Outline Style causes CSS output order to change and cause conflicts

5 participants