Skip to content

Conversation

@ramonjd
Copy link
Member

@ramonjd ramonjd commented Nov 25, 2025

What?

After #72464, block style variation previews stopped working.

This PR fixes that by passing in the required variationStyles option from <GlobalStylesUI /> to inform transformToStyles that it needs to generate variation styles.

Props to @tellthemachines for spotting this one in #73533 (review)

Why?

So the variation styles work.

How?

Pass in the object, yo!

Testing Instructions

Activate TT5 or some other theme with block variations.

Head to /wp-admin/site-editor.php?p=%2Fstyles&section=%2Fblocks%2Fcore%252Fgroup (using TT5, which has group variations)

Check that you can see the preview of your changes to each variation.

Screenshots or screencast

Before

Kapture.2025-11-25.at.17.44.26.mp4

After

Kapture.2025-11-25.at.17.42.00.mp4

@ramonjd ramonjd self-assigned this Nov 25, 2025
@github-actions
Copy link

github-actions bot commented Nov 25, 2025

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: ramonjd <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>

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

@ramonjd ramonjd 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 Nov 25, 2025
disableLayoutStyles,
disableRootPadding
disableRootPadding,
{ variationStyles: true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there cases where this need to be "false"?

Copy link
Contributor

Choose a reason for hiding this comment

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

transformToStyles is setting it to false by default so presumably there are instances where it needs to be false. I'm not sure which ones they are though 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

According to the implementation PR, yes

As the new section styles feature requires styles generated per application of block style variations so they can be nested, there's superfluous CSS generated in the frontend theme.json stylesheet.

My change reinstates that duplication. I think maybe only the GlobalStylesUI needs to generate variations styles - they'll then be passed to the BlockEditorProvider wrapping the preview and other controls

cc @aaronrobertshaw for fact check

Copy link
Member Author

Choose a reason for hiding this comment

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

I think maybe only the GlobalStylesUI needs to generate variations styles

The recent commit does that 0afbe6c

No more duplicates in the editor canvas 🚀

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the quick turnaround addressing that.

Your read on things was correct. If every generation of global styles created the variation styles they'd include ones with the generic block type's selector. The latest update here restore the ability to skip variation style generation avoiding the effective duplicates as noted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice. Thanks for the reviews, everyone!

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! The preview now works correctly for all block style variations.

…enerateGlobalStyles function in render.tsx and update GlobalStylesUI to utilize this new option.
@ramonjd ramonjd merged commit 791c83f into trunk Nov 26, 2025
38 of 39 checks passed
@ramonjd ramonjd deleted the fix/variation-preview-global-styles branch November 26, 2025 01:31
@github-actions github-actions bot added this to the Gutenberg 22.2 milestone Nov 26, 2025
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.

Bit slow to the party but this tests well for me also.

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

None yet

Development

Successfully merging this pull request may close these issues.

5 participants