Skip to content
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 block library and global styles stylesheet ordering when a block style variation is active #63918

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Jul 25, 2024

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
Copy link

github-actions bot commented Jul 25, 2024

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
Copy link
Member

ramonjd commented Jul 25, 2024

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.

Copy link
Contributor

@andrewserong andrewserong left a comment

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! 🚀

Copy link
Member

@ramonjd ramonjd left a comment

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

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

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
65 checks passed
@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
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
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
Copy link
Contributor Author

talldan commented Aug 8, 2024

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
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
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