-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block selectors API: use whole selectors for duotone #49436
Conversation
The old API didn't have the whole selector, just parts of it, so we need to add the root.
Flaky tests detected in dac72ae. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4553951873
|
Before: .wp-duotone .wp-block-name After: .wp-duotone.wp-blockname
$scopes = explode( ',', '.' . $filter_id ); | ||
$selectors = explode( ',', $duotone_selector ); | ||
|
||
$selectors_scoped = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I hadn't to paste this here, but I need this to work differently than the WP_Theme_JSON_Gutenberg::scope_selector
.
Ideas for a follow-up PR:
- Create a utility
css_scope_selector( $scope, $selector )
function somewhere and make it work like this code (no spaces added). - The consumer should be responsible for adding or not adding spaces:
css_scope_selector( $scope . ' ', $selector )
if the consumer wants spaces.css_scope_selector( $scope . ' ', $selector )
if the consumer doesn't want spaces.
Thoughts?
$root_selectors = explode( ',', $root_selector ); | ||
$duotone_selectors = explode( ',', $partial_duotone_selector ); | ||
|
||
$duotone_selector = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use the existing WP_Theme_JSON_Gutenberg::scope_selectors
function, I guess. This function merits to be its own utility, given how much it has expanded: settings, duotone, WP_Theme_JSON class.
@@ -85,7 +85,6 @@ | |||
"supports": { | |||
"anchor": true, | |||
"color": { | |||
"__experimentalDuotone": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I found by reviewing the duotone code (not related to this PR):
gutenberg/lib/class-wp-duotone-gutenberg.php
Line 281 in 70198b9
$duotone_support = (bool) $duotone_selector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is needed to enable the filter controls in the block toolbar.
Closing in favor of #49423 |
What
Tentative fix for #49393 (comment)
Why
The Block Selectors API is meant to land in 15.5 but duotone works differently than any other selector. The global-level duotone style is also broken.
How
wp_get_block_css_selector
returns the whole selector for duotone, even if the old API is in use 7f6b31dTODO
Test
selectors.filter.duotone
) and two cover blocks (supports.color.__experimentalDuotone
).purple-green
duotone for one of the images and one of the covers.The expected result is that the blocks with block-level duotone have it applied and the other ones use the global-level duotone in any context (front-end, post editor, site editor).
No other
img
elements of the page have any duotone applied (check the user avatar at the top-right, for example).