Repository navigation
Global Styles: Scope custom block state styles to feature selectors - #15915
aaronrobertshaw wants to merge 3 commits into
Conversation
Custom block states in theme.json, such as Navigation Link's `-current`, passed the block's feature selectors through unchanged, so a style with its own feature selector applied to every instance of the block, and `-current:hover` lost its `:hover`. This appends the state selector, wrapped in `:is()`, to each feature and subfeature selector, and the pseudo selector on top for custom state pseudo nodes. Follow-up to [62641].
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Backport of Gutenberg PR WordPress/gutenberg#86640
Trac ticket: https://core.trac.wordpress.org/ticket/66667
Styles in a custom block state, such as Navigation Link's
-current, now stay scoped to that state. This covers features with their own selector. Before, they applied to every instance of the block, and-current:hoverlost its:hover.This PR backports:
WP_Theme_JSON::get_block_nodes(),WP_Theme_JSON::append_to_feature_selectors()helper, also used by pseudo state nodes with no output change,WP_Theme_JSONtests.Testing instructions
Navigation Link has no feature selectors in Core yet, so a filter adds one. No editor or package update is needed.
wp post update 2 --post_content='<!-- wp:navigation --><!-- wp:navigation-link {"label":"Sample Page","type":"page","id":2,"kind":"post-type"} /--><!-- /wp:navigation -->'color: red,min-width: 200pxandmin-height: 60px. With this PR::hover, so every link gets both sizes:Use of AI
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: The port, tests and output check were done by Claude Code; I reviewed them.