Skip to content
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

Overlay color controls not toggleable in 6.1+ #50046

Closed
snovosel-godaddy opened this issue Apr 24, 2023 · 4 comments · Fixed by #50115
Closed

Overlay color controls not toggleable in 6.1+ #50046

snovosel-godaddy opened this issue Apr 24, 2023 · 4 comments · Fixed by #50115
Assignees
Labels
[Feature] Colors Color management [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Comments

@snovosel-godaddy
Copy link

Description

In previous versions of WP the core color settings are disabled entirely based on the settings object being passed an empty color or gradient array. However, in versions 6.1+ , the color controls panel will still show (even with color controls disabled) for the overlay color. This same panel will not show if color settings are disabled for both background or text colors.

In the case where an empty palette is passed to the settings object, the panel is visible and an empty palette is present as shown in the below photo

Screen Shot 2023-04-24 at 3 15 07 PM

Step-by-step reproduction instructions

Set the following settings in the editor:

    settings.colors = [];
    settings.gradients = [];
    settings.disableCustomColors = true;
    settings.disableCustomGradients = true;
    settings.__experimentalFeatures.appearanceTools = false;
    settings.__experimentalFeatures.color.defaultDuotone = false;
    settings.__experimentalFeatures.color.text = false;
    settings.__experimentalFeatures.color.background = false;
    settings.__experimentalFeatures.color.palette.default = [];
    settings.__experimentalFeatures.color.palette.theme = [];
    settings.__experimentalFeatures.color.gradients.default = [];
    settings.__experimentalFeatures.color.gradients.theme = [];

add core/cover block. notice that the color settings panel is still visible in the side bar, however the palette container shows an empty div.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

@Mamaduka Mamaduka added Needs Testing Needs further testing to be confirmed. Needs Technical Feedback Needs testing from a developer perspective. [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor [Feature] Colors Color management and removed Needs Testing Needs further testing to be confirmed. Needs Technical Feedback Needs testing from a developer perspective. labels Apr 25, 2023
@Mamaduka
Copy link
Member

I can confirm the issue.

Currently, there's no check if returned values from useMultipleOriginColorsAndGradients are truthy, and block-specific color panels are always rendered.

@aaronrobertshaw, I remember you worked on recent refactoring/unification of color panels. What do you think about returning the additional hasColorsOrGradients value from the hook and using it as a condition before rendering these panels?

@aaronrobertshaw
Copy link
Contributor

Thanks for the ping 👍

I don't think we can apply a blanket rule to disable the Color panel if color supports have been disabled. As the panel is rendered via a SlotFill, it could be possible for a theme or plugin to disable the color supports but render their own custom controls into the Color panel.

The catch here with the Cover block is that the overlay and opacity controls are ad hoc controls added to the Color panel slot by Cover block. I've put together #50115 which will only render the overlay and opacity controls if there are colors.

Another contrived example to illustrate color related controls perhaps being desirable even without color support being enabled might be as follows:

  • Theme author disables color support
  • Sets a uniform overlay color on all Cover blocks
  • Still wants to allow users to tweak the overlay's opacity
Screen.Recording.2023-04-27.at.2.55.23.pm.mp4

@Mamaduka
Copy link
Member

Mamaduka commented Apr 27, 2023

Thanks for looking into this, @aaronrobertshaw.

I wasn't suggesting a blanket solution; I understand that each block's implementation is different.

My suggestion/plan:

We don't have to update all blocks in a single PR, but having a unified way of handling checks would be nice.

Edit: I'll happily handle updates if this method looks good to you.

@aaronrobertshaw
Copy link
Contributor

Thanks for the clarification, I misunderstood.

I can update the hook to return the additional flag. I also still need to update #50115 to fix the failing tests for the Cover block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Colors Color management [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants