Repository navigation
theme.json schema: block level pseudo-classes for core/button & core/navigation-link - #81073
yashjawale wants to merge 3 commits into
Conversation
… core/navigation-link only
|
Another approach would be to change regex of Can work since all core blocks are already explicitly listed in |
…head for button and navigation-link only
|
Update the PR to use a negative lookahead regex that excludes With this third party blocks (or any other blocks that aren't explicitly listed) continue to get strict checking instead of falling through. For more details of the previous approach view the previous version of the PR description. |
core/button & core/navigation-linkcore/button & core/navigation-link
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| "$ref": "#/definitions/stylesBlocksPseudoSelectorsProperties" | ||
| }, | ||
| { | ||
| "$ref": "#/definitions/stylesBlocksCustomStatesProperties" |
There was a problem hiding this comment.
Looks like stylesBlocksCustomStatesProperties is no longer used?
There was a problem hiding this comment.
Also, by deleting these we're losing the descriptions, i.e., "description": "Custom class-based block states using the '-' prefix. Each state supports style properties as well as the same pseudo-selectors available to the block.",
| "variations": { | ||
| "$ref": "#/definitions/stylesVariationsPropertiesComplete" | ||
| }, | ||
| "-current": { |
There was a problem hiding this comment.
#/definitions/stylesBlocksCustomStatesProperties already had -current. Couldn't we have used it?
There was a problem hiding this comment.
Actually, that orphaned definition still contains the original bug (stylesPropertiesComplete pins propertyNames), so whoever $refs it next silently reintroduces this exact issue.
|
Thanks for getting this PR open. I haven't tested it manually yet. A couple of things popped up:
It's hard to cover everything... so I got a draft alt PR up to illustrate: |
|
Ah right... That looks a lot better |
If that's okay, thank you for understanding and kicking this off! I'll close and move things over to the new PR #81209. 🙇🏻 |
What?
Closes #81057
This PR whitelists block-level pseudo-classes in the theme.json schema for core/button and core/navigation-link only, by making the block-fallback schemas permissive so per-block definitions are authoritative.
Why?
Currently pseudo classes for
core/buttonandcore/navigation-linkare flagged by IDE validators based ontheme.jsonschema. However, the support for them was previously added & the schema should reflect the same but allowing those properties.How?
The strict generic
patternPropertiesfallback was overriding every block's definition, so pseudo-classes were getting rejected on all blocks (including the two that are supported). This PR excludescore/buttonandcore/navigation-linkfrom that fallback via a negative lookahead regex, leavingcore/buttonuntouched and adding explicit pseudo-class (+ -current) support tocore/navigation-linkin both the main and variation block styles.Now only the two runtime-supported blocks accept
:hover/:focus/:focus-visible/:active, while all other blocks correctly reject them — including third-party blocks, which continue to be validated against the strict generic fallback.However, one caveat of this approach is that the negative lookahead must be kept in sync with runtime support. Any future block that gains pseudo-class support needs to be added to the lookahead (and its explicit definition expanded) for its pseudo-classes to validate.
Testing Instructions
theme.jsonfile with the sample data.Sample theme.json
{ "$schema": "https://schemas.wp.org/wp/6.8/theme.json", "version": 3, "styles": { "blocks": { "core/button": { "color": { "background": "yellow", "text": "blue" }, ":hover": { "color": { "background": "red" } } } } } }$schemaproperty value to be schema file in this branchUse of AI Tools
Assisted by DeepSeek V4 Flash via Opencode
All changes reviewed & tested manually.