-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Color Palette: Respect defaultPalette setting (fixes Cover block placeholder state) #58869
Color Palette: Respect defaultPalette setting (fixes Cover block placeholder state) #58869
Conversation
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. |
Size Change: -40 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Whoops! I missed that unit tests will need updating, too, I see the Cover block ones are failing now. I'll take a look 👀 |
Updated in f51fc73 — it turns out the tests depended on the bug, as they first created the block by selecting a colour from the default palette, which shouldn't have been rendered. That's fixed up now, and I believe this PR should be ready for review. |
Flaky tests detected in f51fc73. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7839380140
|
In WP 6.4 running TT4 without Gutenberg, toggling Or is that intentional? 😅 |
I'm having difficulty working out what the intended behaviour of gutenberg/schemas/json/theme.json Line 148 in 5939c41
Based on #39966, it seems that the intention is that it only controls whether the default palette appears in this popover:
(Both screenshots taken in an environment running WP 6.4 without the plugin.) So I think what I noticed in #58869 (comment) is a bug/regression and that the placeholder should always only show theme colours. |
In the context of this PR, yes, that was my intention — it ensures the behaviour is consistent with the Background or Color panels where if the default palette is enabled, the default colors are available to choose from:
It's a good question, but I think the answer depends on what we think of the discussion from #55219 — prior to that PR (in 6.4), the |
Update: after discussing some of the ideas here with @noisysocks, I've pushed an update to the Cover block so that it'll only show the default color palette if there are no theme colors. So, in a site that has custom and theme colors, and with Some of the considerations thus far:
@richtabor / @WordPress/gutenberg-design does this PR roughly match expected behaviour now? |
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.
Thanks for working on this @andrewserong 👍
It's testing as advertised for me.
Given @noisysocks discussions with you it might be prudent to wait on his approval though.
Also, given we have some tests for the Cover block it might be good to lean into that and add one here around the available colors in the placeholder. What do you think?
@@ -318,7 +318,19 @@ function CoverEdit( { | |||
const blockProps = useBlockProps( { ref } ); | |||
|
|||
// Check for fontSize support before we pass a fontSize attribute to the innerBlocks. |
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.
Should we update this comment to reflect recent changes? There's a bit more going on now than just checking fontSize support.
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.
Oh, yes, of course, I'll update this tomorrow 👍
Great idea. I'll let this PR simmer overnight, and then I'll add in another one for the new behaviour here 👍 |
Update: from the discussion over in #55219 (comment), it sounds like folks might be considering going with reverting #55219, in which case we wouldn't need this fix in the shorter-term. Just in case, I've updated this PR with a few more tests, so that if the decision is not to revert that PR, we can still go with this fix. Happy to either go with this, or close it out as needed! |
Let's see what comes of #58951 first. |
Closing in favour of #58951 since it has a few approving reviews. Assuming that one lands, I might open a follow-up PR that is fairly similar to this one, but an enhancement for 6.6 instead of a bug fix for 6.5. That is, to allow combined custom color + theme color buttons in the Cover block's placeholder, as with #58951 the custom color palette will override the theme color palette instead of the two being merged. |
What?
Fixes: #58753
Update the
ColorPalette
component used by the Cover block's placeholder state so that it is aware of thecolor.defaultPalette
setting, and therefore can skip outputting the default palette when required.Why?
This was raised in: #58753 and from a git bisect, it seems that the PR that originally caused this to regress was: #55219
If my understanding is correct, #55219 resulted in combining the values for all origins into
color.palette
since it's included in the__EXPERIMENTAL_PATHS_WITH_MERGE
object here. So, after that PR, and prior to this one,'color.palette'
will automatically include all the default palettes in it.So that means one solution is to:
How?
custom
,theme
, anddefault
colors separately, and combine them, skipping thedefault
colors ifcolor.defaultPalette
is falsy.color.defaultPalette
is not enabled.colors
value, that will only show the default palette colors if there are no theme colors, and if thecolor.defaultPalette
value is truthy.I'm not sure if this is the best way to fix it, but it seems to do the job so far!
Testing Instructions
trunk
if you add a Cover block to a post, page, or template, you'll see the default colors in addition to theme or custom colors in the placeholderdefaultPalette
), you should only see theme + custom colors in the placeholdersettings.color.defaultPalette
intheme.json
— switching it totrue
should re-enable the display of the default colors again — they will be visible when highlighting text, and in the using color pickers. In the Cover block placeholder, however, we only show the default palette if there are no theme colors available.Screenshots or screencast
color.defaulPalette
is set totrue
)This should also fix an issue with the colors displayed when highlighting text, too: