#57585 closed enhancement (fixed)
Editor: Make block type aware of selectors prop
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Editor | Keywords: | has-patch has-unit-tests needs-dev-note gutenberg-merge changes-requested |
Focuses: | Cc: |
Description
In Gutenberg, an API was introduced to allow blocks to define custom CSS selectors for use in theme.json stylesheet generation. This was previously an experimental API contained within a block's block.json supports
property.
It would be great to stabilize this API, making it a first-class citizen of the block.json schema. For this to occur, we must add selectors
to the block type schema within core WP.
The original proposal regarding the selectors API can be found here:
The Gutenberg PR implementing the stabilized selectors API can be found here:
The new field should be included within the WP_Block_Type
class, in the REST API endpoint for block types, and exposed in the get_block_editor_server_block_settings
function.
Change History (18)
This ticket was mentioned in PR #3942 on WordPress/wordpress-develop by @aaronrobertshaw.
2 years ago
#1
- Keywords has-patch has-unit-tests added
2 years ago
#2
It's nearly ready from my perspective. I left my comments, and deciding on the default value is the only important thing.
#3
@
2 years ago
- Keywords needs-dev-note commit added
- Milestone changed from Awaiting Review to 6.3
- Owner set to gziolo
- Status changed from new to assigned
@aaronrobertshaw commented on PR #3942:
2 years ago
#4
@gziolo there have been a few changes here. I've added a second property to block types for editor-only selectors. Some background for this change can be found over on the related Gutenberg PR (https://github.com/WordPress/gutenberg/pull/46496#issuecomment-1464031044).
Essentially, we went with the second property to match the existing style
/ editorStyle
block type properties, so we'll offer selectors
/ editorSelectors
.
2 years ago
#5
Essentially, we went with the second property to match the existing
style
/editorStyle
block type properties, so we'll offerselectors
/editorSelectors
.
Sounds good, and the code changes look correct. I'm not sure why e2e tests failed on CI but I restarted the job to see if that was only an incident.
@aaronrobertshaw commented on PR #3942:
2 years ago
#6
I'm not sure why e2e tests failed on CI but I restarted the job to see if that was only an incident.
Seems like you had the magic touch 🪄
I'd already re-run it twice before rebasing the PR and having it fail again.
#8
@
2 years ago
- Keywords changes-requested added; commit removed
Some coding standards changes are requested on https://github.com/WordPress/wordpress-develop/pull/3942.
@aaronrobertshaw commented on PR #3942:
2 years ago
#9
👍 Thanks for the feedback @hellofromtonya. I believe I've addressed all of that now in https://github.com/WordPress/wordpress-develop/pull/3942/commits/82d1762b4bc5a9e8eaf114a58022f74302f7a973
@aaronrobertshaw commented on PR #3942:
2 years ago
#10
👍 Thanks for the feedback @hellofromtonya. I believe I've addressed all of that now in https://github.com/WordPress/wordpress-develop/pull/3942/commits/82d1762b4bc5a9e8eaf114a58022f74302f7a973
@aaronrobertshaw commented on PR #3942:
2 years ago
#11
There were some concerns raised around introducing support for editor-only selectors on the Gutenberg PR. For the time being, we'll remove that editor-only support so it can be discussed further and added at a future date.
As such, I've reverted the addition of editor selectors to block types here.
2 years ago
#12
@aaronrobertshaw, it's been a while since all the changes landed in the Gutenberg plugin. Do you think it's good to go for WordPress core?
@aaronrobertshaw commented on PR #3942:
2 years ago
#13
Thanks for the nudge @gziolo!
After the removal of the editor-only selectors from this API, it doesn't seem like there is a great appetite yet to see them return. I suspect it might take some time to find solutions to the issues facing editor-only selectors.
Given that, I believe the changes here are stable and as you note the Selectors API landed in Gutenberg 15.5 so they've in the wild for a little while.
There's no objections from my end to see this land in core 🙂
2 years ago
#15
Committed with https://core.trac.wordpress.org/changeset/55673.
#16
@
21 months ago
Do we have a volunteer to write the Dev Note for this ticket?
https://github.com/orgs/WordPress/projects/108/views/11
Thanks.
#17
@
21 months ago
I've created a draft Dev Note here: https://make.wordpress.org/core/wp-admin/post.php?post=106203&action=edit
Unfortunately, I'll be AFK for a little over a week in the lead up to the 6.3 RC. Please feel free to edit, copy into a new post, or otherwise hack at that draft to get it into shape.
This PR adds support for the new
selectors
property. It adds it to the allowed metadata when registering a block type, makes theWP_Block_Type
class aware of it, exposes it through the block types REST API, and theget_block_editor_server_block_settings
function.There is a corresponding Gutenberg PR (https://github.com/WordPress/gutenberg/pull/46496) that stabilizes the block.json
selectors
API and in part depends upon the changes here.Trac ticket: https://core.trac.wordpress.org/ticket/57585