Update Theme JSON $schema to allow pseudo selectors on button property#44303
Conversation
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @blindingstars! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
getdave
left a comment
There was a problem hiding this comment.
This looks good to me. Matches the work we did for link element.
At some point we can DRY this up, but it's not necessary at this point.
Thank you for taking the time to contribute - it's much appreciated 🙇
|
The failing e2e test isn't related to this change (See #44350), so I'm going to merge the PR. Thanks for contributing, @blindingstars! |
|
Congratulations on your first merged pull request, @blindingstars! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
What?
Provide better IDE feedback to show that the pseudo selectors
:hover,:focus, and:activeare allowed on thebuttonpropertySee also:
elementsin theme json #41786: Pseudo selector support enabled$schemato account for pseudo selector support #41936: Pseudo selectors allowed onlinkpropertiesWhy?
Improving the developer experience – anecdotally, I was trying to implement a button hover style in a full-site theme but wasn't certain that I was doing so the right way since the schema was disallowing my solution
How?
Update the schema for top-level and interior blocks to allow the valid pseudo selectors
:hover,:focus, and:activeon thebuttonpropertyAs mentioned in #41936, this adds some code duplication and is not the DRYest solution. If this were implemented for all of the other properties in the same manner, we'd be extremely redundant. However, links and buttons are both very standard properties to support pseudo selector states; I feel that it's fair to add a small bit of duplication to support such a common use.
Testing Instructions
theme.jsonfile and update the$schemato point to your local Gutenberg version do the schema file (e.g."$schema": "file:///Users/{{YOUR_USER}}/Sites/gutenberg/schemas/json/theme.json").:hover,:focus, and/or:active) underelements.buttonand{{BLOCK_NAME}}.elements.buttonand make sure your editor does not show any warnings or errors.:empty) and make sure your editor flags them as disallowed.h2) and make sure your editor flags them as disallowed.Shamelessly adapted from #41936
Screenshots or screencast
Before
Common
buttonpseudo selectors are disallowed even though they are functional and follow the same format/pattern aslink:After
Allowed pseudo selectors no longer show up as errors, but disallowed ones still do: