Make WordPress Core

Opened 2 days ago

Last modified 21 hours ago

#66313 new enhancement

Block Supports: Output per-block styles for custom style states

Reported by: onemaggie Owned by:
Priority: normal Milestone: 7.2
Component: Editor Version:
Severity: normal Keywords: has-patch has-unit-tests gutenberg-merge
Cc: Focuses:

Description

Block style states can style a Navigation Link's current menu item (-current) in theme.json, and Gutenberg now lets you set that state per block too. This adds the matching per-block CSS output to the states block support, scoped to the selector the block declares in selectors.states.

Gutenberg PR: ​https://github.com/WordPress/gutenberg/pull/78769

Change History (2)

This ticket was mentioned in ​PR #14285 on ​WordPress/wordpress-develop by ​@onemaggie.


2 days ago
#1

Backport of Gutenberg PR ​https://github.com/WordPress/gutenberg/pull/78769

Trac ticket: https://core.trac.wordpress.org/ticket/66313

A block's style attribute can now style a custom state, such as Navigation Link's -current for the current menu item, including its nested pseudo states and inside a viewport. The per-block rules scope the block's wp-states-* class to the selector the block declares in selectors.states, wrapped in :is(), so a feature selector keeps the state on the block's wrapper: .wp-states-1a2b3c4d:is(.wp-block-navigation .current-menu-item) > .wp-block-navigation-item__content.

This PR backports:

  • wp_get_custom_state_selector_suffix() and wp_get_custom_state_style_rules(),
  • the custom state handling in wp_render_block_states_support(),
  • and the accompanying states block support tests.

Use of AI Tools

Ported with Claude Code (Opus 5.5). All output reviewed and validated by the author.

🤖 Generated with ​Claude Code

#2 @im3dabasia1
21 hours ago

I’m going through the 7.2 tickets ahead of beta 1.

Thank you for the work on this, @onemaggie.

I see the Gutenberg ​PR has had some activity recently, which is great to see. With beta 1 only a few days away, is 7.2 a realistic target?

Note: See TracTickets for help on using tickets.