Block Style States: Add @current custom state for Nav Link#78769
Draft
MaggieCabrera wants to merge 7 commits into
Draft
Block Style States: Add @current custom state for Nav Link#78769MaggieCabrera wants to merge 7 commits into
MaggieCabrera wants to merge 7 commits into
Conversation
|
Size Change: +801 B (+0.01%) Total Size: 8.44 MB 📦 View Changed
|
9e53351 to
80ad5da
Compare
|
Flaky tests detected in 4223a4b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27193382063
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #38277. Part of #77817.
Adds the
@currentstate to Block Style States so a user can style the active menu item forcore/navigation-link, in the block inspector and in Global Styles. Third state axis after pseudo (#76491) and responsive (#78384), and the first custom (class-based) state to ship.Why?
Until now, theming the current menu item meant hand-writing theme.json or custom CSS.
@currentis the canonical use case for a class-based state, WordPress applies.current-menu-itemat render time when a link's URL matches the request.How?
selectors.states["@current"]onnavigation-link/block.jsonis a class fragment (.current-menu-item), not a full selector. Both consumers compose it under the block's root selector viaappend_to_selector().StateMenuGroupso the three dropdown groups share one source of truth.Selector shape (kept-on-purpose tradeoff, #75736)
The team split on
@current's CSS shape: @scruffian preferred the broad.wp-block-navigation .current-menu-item; @talldan preferred the narrow.wp-block-navigation-link.current-menu-item. This PR lands on talldan's form. Side effect: the Global Styles output shape for@currentchanges. Needs Dev Note.Not in this PR
add/nav-link-style-supports. Until that lands, only typography is visible under@currentin the block inspector. Global Styles is unaffected (it exposes the full panel).selectors.states— follow-up.block.jsonopt-in for third-party blocks — still deferred per Update state support to use config instead of block supports #78088.Testing Instructions
Screenshots
States dropdown on Global Styles:
Frontend:
Use of AI Tools
Authored with Claude Code (Opus 4.7). All output reviewed and validated by the author.