Skip to content

Editor: Output per-block styles for custom style states - #14285

Open
MaggieCabrera wants to merge 1 commit into
WordPress:trunkfrom
MaggieCabrera:backport/78769
Open

MaggieCabrera wants to merge 1 commit into
WordPress:trunkfrom
MaggieCabrera:backport/78769

Conversation

@MaggieCabrera

Copy link
Copy Markdown

Backport of Gutenberg PR WordPress/gutenberg#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

Lets a block's `style` attribute 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.

Backports WordPress/gutenberg#78769.

See #66313.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaggieCabrera added a commit to WordPress/gutenberg that referenced this pull request Oct 14, 2026
Links WordPress/wordpress-develop#14285, which backports the custom
state output in `lib/block-supports/states.php`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@MaggieCabrera
MaggieCabrera marked this pull request as ready for review October 14, 2026 23:29
@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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props onemaggie.

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

MaggieCabrera added a commit to WordPress/gutenberg that referenced this pull request Oct 19, 2026
Links WordPress/wordpress-develop#14285, which backports the custom
state output in `lib/block-supports/states.php`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant