Opened 6 months ago
Closed 5 months ago
#65239 closed enhancement (fixed)
Add support for style states on block instances
| Reported by: | isabel_brison | Owned by: | isabel_brison |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | gutenberg-merge has-patch has-unit-tests |
| Cc: | Focuses: |
Description
https://github.com/WordPress/gutenberg/pull/76491 adds a new "states" block support, intended to allow styling pseudo states, custom block states such as "current menu item" and specific viewport sizes. This needs adding to core.
Change History (11)
This ticket was mentioned in PR #11828 on WordPress/wordpress-develop by @isabel_brison.
6 months ago
#1
- Keywords has-patch added
#2
@
6 months ago
Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.
#3
@
6 months ago
- Version trunk
Since this is an enhancement, there's no first version of WordPress this can be reproduced in. Removing trunk version.
@isabel_brison commented on PR #11828:
5 months ago
#4
@andrewserong regarding the missing tests, I did omit some that were expecting button width migration changes to already be in place. Those should be added in #12046, so once that one is committed we can add a few more tests if needed.
@andrewserong commented on PR #11828:
5 months ago
#5
Ah, perfect. Thanks for clarifying!
@aaronrobertshaw commented on PR #11828:
5 months ago
#7
Just a quick note that this will mean the background gradient vs color bug introduced in https://github.com/WordPress/gutenberg/pull/76491 will still need a follow-up in core too.
#8
@
5 months ago
- Resolution fixed
- Status closed → reopened
Reopening to add a related bug fix (see https://github.com/WordPress/gutenberg/pull/78992)
#9
@
5 months ago
I've opened a PR for it - https://github.com/WordPress/wordpress-develop/pull/12182
This ticket was mentioned in PR #12182 on WordPress/wordpress-develop by @iamchitti.
5 months ago
#10
- Keywords has-unit-tests added
Backport of WordPress/gutenberg#78992.
## Description
When a block instance has a gradient applied to its default state and a solid background color applied to a pseudo-state like
:hover, the hover color never appears — the gradient keeps showing despite the state styles using!important.
This is a CSS property mismatch: gradients render as background (shorthand) or background-image, while solid colors render as background-color. Since !important only resolves ties between declarations of the *same* property, the gradient image layer is never cleared by the hover rule.
## Changes
Added wp_get_state_declarations_with_background_resets() in src/wp-includes/block-supports/states.php, called alongside the existing wp_get_state_declarations_with_fallback_border_styles().
When compiled state declarations include background-color but no background or background-image of their own, it appends background-image: unset !important to clear any gradient from the default state.
This mirrors the existing border-style fallback pattern already in the states support, and covers both:
- Legacy
color.gradientpath (emitsbackgroundshorthand) - Modern
background.gradientpath (emitsbackground-image)
Trac ticket: https://core.trac.wordpress.org/ticket/65239
## Use of AI Tools
No use of AI.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: https://core.trac.wordpress.org/ticket/65239
## Use of AI Tools