-
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
The new blockEditor.useSetting.before filter does not appear to be working with background color #49173
Comments
cc @ingeniumed @alecgeatches @aaronrobertshaw I am going to add this to the 6.2 Board for now since this seems to be a bug and is related to a new feature in 6.2, but it's not a blocker. |
It is a bit complicated, but I think the gradient setting also needs to be completely disabled. The following code will hide the Background Color panel: wp.hooks.addFilter(
'blockEditor.useSetting.before',
'myPlugin/useSetting.before',
( settingValue, settingName, clientId, blockName ) => {
if ( blockName === 'core/heading' ) {
if ( settingName.startsWith( 'color.gradients.' ) ) {
return [];
}
if ( settingName === 'color.background' || settingName === 'color.customGradient' ) {
return false;
}
}
return settingValue;
}
); |
Ah thanks @t-hamano! I will do some more testing on this next week, because I’m curious if the same thing happens when disabling background color at the block level in theme.json. |
Thanks for the ping @ndiego 👍 As @t-hamano indicated I don't think this is an issue with the There are some existing issues for this already including #41293 & #45273. My suggestion here would be to close this one as a duplicate. |
@aaronrobertshaw yeah, upon further testing, it all looks to be the same situation. I'll make sure to add this callout in the documentation I'm working on. Thanks for the follow-up. 💪 Closing this out as a duplicate of #41293. |
Description
While testing the new
blockEditor.useSetting.before
, I found that it doesn't appear to work when trying to disable thecolor.background
setting on blocks. It's quite strange since disablingcolor.link
andcolor.text
work as expected. I'm unsure if this is an isolated issue or hints at a larger bug with this filter, but I will follow up if I find any others.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
In functions.php
In filters.js
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: