Skip to content

Hide block style variations when state is enabled in global styles - #80341

Merged
tellthemachines merged 1 commit into
trunkfrom
fix/global-styles-states-variations
Jul 16, 2026
Merged

tellthemachines merged 1 commit into
trunkfrom
fix/global-styles-states-variations

Conversation

@tellthemachines

Copy link
Copy Markdown
Contributor

What?

Quick fix for something I noticed while testing #80339

Testing Instructions

  1. In global styles, select a block with style variations and pseudo states (e.g. Button)
  2. Enable different states (viewport and pseudo) and check that the style variations don't display when those states are enabled:

Default state:

Screenshot 2026-07-16 at 3 00 58 pm

Non-default state:

Screenshot 2026-07-16 at 3 01 08 pm

@tellthemachines tellthemachines self-assigned this Jul 16, 2026
@tellthemachines tellthemachines added [Type] Bug An existing feature does not function as intended [Feature] Style States Related to block style states (currently viewport and pseudo-states) Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 16, 2026

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

It looks like this also hides the style variations buttons if Hover is selected. However, it's possible on trunk to style the Hover style variation of the Button block:

Image

That said, it's not necessarily a blocker as you can still click into Outline before selecting "Hover", and then once you're in the Outline variation select the "Hover" state. Also, because the selected pseudo state doesn't survive a navigation change, if a user is on "Hover" when at the parent level of the Button block, they'll have to reselect Hover anyway once they go into the Outline style variation.

So, IMO not a big deal to hide the variations panel if any state is selected. Just thought I'd mention it if it feels like a concern or if there's a simple way to hide only if it's a viewport selected.

Here's a video of the above behaviour:

2026-07-16.15.16.05.mp4

Tentative LGTM 😄

@github-actions

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: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

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

@tellthemachines

Copy link
Copy Markdown
Contributor Author

Also, because the selected pseudo state doesn't survive a navigation change, if a user is on "Hover" when at the parent level of the Button block, they'll have to reselect Hover anyway once they go into the Outline style variation.

This also happens with the other states: if you're on tablet and select a variation, you then have to re-select tablet once in it. It makes me think it's better to hide the variations if a state is selected so the path to styling a variation is unambiguous.

@tellthemachines
tellthemachines enabled auto-merge (squash) July 16, 2026 05:26
@andrewserong

ghost commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

It makes me think it's better to hide the variations if a state is selected so the path to styling a variation is unambiguous.

Sounds good to me! In that case, my tentative LGTM is now simply a normal LGTM 😄

@github-actions

ghost commented Jul 16, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.72 MB

compressed-size-action

@tellthemachines
tellthemachines merged commit 4e91395 into trunk Jul 16, 2026
@tellthemachines
tellthemachines deleted the fix/global-styles-states-variations branch July 16, 2026 05:36
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 16, 2026
@github-actions github-actions Bot removed the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 16, 2026
@github-actions

ghost commented Jul 16, 2026

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: f836355

@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Jul 16, 2026
@t-hamano t-hamano added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jul 17, 2026
@t-hamano

ghost commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

I just cherry-picked this PR to the release/23.6 branch to get it included in the next release: 7525db2

@t-hamano t-hamano removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jul 21, 2026
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 [Feature] Style States Related to block style states (currently viewport and pseudo-states) [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants