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

bug:theme.json controls core/cover overlay opacity via settings.color.defaultGradients #54140

Open
tresorama opened this issue Sep 3, 2023 · 3 comments
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Inspector Controls The interface showing block settings and the controls available for each block [Type] Bug An existing feature does not function as intended

Comments

@tresorama
Copy link

Description

I don't know if it is supposed to work like this but i found it unintuitive.
If i disable the entire settings.color property, (not settings.blocks.core/cover.color) to prevent color usage this cause the core/cover to lose abilty to control the overlay opacity.

Trying to reenabling it, it is necessary to enable settings.blocks.core/cover.color.defaultGradients.

It doesn't make sense for me.

Step-by-step reproduction instructions

  1. Use this theme json
{
  "version": 2,
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "settings": {
    "color": {
      "defaultPalette": false,
      "defaultDuotone": false,
      "defaultGradients": false,
      "custom": false,
      "customDuotone": false,
      "customGradient": false,
      "background": false,
      "link": false,
      "text": false,
      "palette": []
    },
    "blocks": {
      "core/cover": {
        "appearanceTools": false,
        "color": {
          "defaultGradients": true
        }
      }
    }
  },
}
  1. Check that overlay opacity control is not present in core/cover
  2. Add
{  
  "version": 2,
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "settings": {
    "color": {
      "defaultPalette": false,
      "defaultDuotone": false,
      "defaultGradients": false,
      "custom": false,
      "customDuotone": false,
      "customGradient": false,
      "background": false,
      "link": false,
      "text": false
    },
    "blocks": {
      "core/cover": {
        "color": {
          "defaultGradients": true
        }
      }
    }
  }
}
  1. Check that overlay control is now present

Screenshots, screen recording, code snippet

No response

Environment info

  • Wordpress 6.3.1
  • NO Gutenberg Plugin

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

@jordesign jordesign added Needs Testing Needs further testing to be confirmed. [Block] Cover Affects the Cover Block - used to display content laid over a background image CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement. labels Sep 4, 2023
@ndiego
Copy link
Member

ndiego commented Sep 5, 2023

Thanks for reporting @tresorama. This is a tricky bug. The overlay slider is part of the Color supports panel in the Setting Sidebar. When all the color controls are disabled, so is the Color support panel, which also causes the slider to be hidden.

This is a larger issue for those wanting to extend Core block support panels. It's almost like we need a check to see if other controls should be displayed, even if those controlled in theme.json are hidden. 🤔

cc @Mamaduka @aaronrobertshaw

@ndiego ndiego added [Type] Bug An existing feature does not function as intended [Feature] Inspector Controls The interface showing block settings and the controls available for each block and removed [Type] Enhancement A suggestion for improvement. Needs Testing Needs further testing to be confirmed. CSS Styling Related to editor and front end styles, CSS-specific issues. labels Sep 5, 2023
@tresorama
Copy link
Author

...The overlay slider is part of the Color supports panel in the Setting Sidebar. When all the color controls are disabled, so is the Color support panel, which also causes the slider to be hidden.

This is what i thought when i'm dealing with it.

But if i remember well, not every settings.blocks.core/cover.color.XXXXX re-enables the color panel ( causing opacity control to be present ).

I tried each of those one by one and the first that worked is defaultGradients , so I stopped there, but maybe also others do the same.
It would be good to check all of them.

This is a larger issue for those wanting to extend Core block support panels. It's almost like we need a check to see if other controls should be displayed, even if those controlled in theme.json are hidden. 🤔

Or detach "overlay" related controls to dedicated settings.color.overlayColor settings.color.overlayOpacity...

@aaronrobertshaw
Copy link
Contributor

Thanks for the ping 👍

From memory, the overlay opacity was thought of as essentially part of the overlay color. It's effectively a shortcut to adjusting the color's alpha. If all color support is disabled, so to then was the overlay, which in turn affects the opacity control.

The disabling of color support and the related panel is very awkward. No arguments here. It prompted me a while back to try and outline all the inconsistencies with disabling block support UIs. Unfortunately, I haven't had the bandwidth to address any of the tasks outlined in that issue.

Personally, I'd probably lean towards keeping the tight coupling between the overlay color and its opacity. It's not a position I hold strongly though if there proves to be a demand for doing the opposite.

You can find some further history and context in previous issues and PRs.

I tried each of those one by one and the first that worked is defaultGradients , so I stopped there, but maybe also others do the same.

You can see in the Cover block's inspector controls where the overlay and overlay opacity controls are conditionally rendered. That condition is based on useMultipleOriginColorsAndGradients which determines whether the block has any colors or gradients.

This is a larger issue for those wanting to extend Core block support panels. It's almost like we need a check to see if other controls should be displayed, even if those controlled in theme.json are hidden.

I believe the block support panels, e.g color, typography etc, will show if there are any fills to render into them. It's why the issue linked above was raised when the thinking was that the overlay and opacity shouldn't be shown if colors were disabled.

It is the cover block itself that omits the overlay controls from the panel not the panel or theme.json themselves. The theme.json settings are using by the block in making that determination though.

Or detach "overlay" related controls to dedicated settings.color.overlayColor settings.color.overlayOpacity

Given overlay isn't a feature within color block supports, I don't think this is a viable option. It's an ad hoc control added by the Cover block which doesn't apply to other blocks adopting color support.

IIRC there has been some discussion in the past around allowing bespoke settings per block-type in the theme.json. It might have been around allowing button width to be disabled. If that feature was added, it might provide the mechanism to control display of ad hoc block controls.

Hopefully, that helps provide a clearer picture of our current situation.

Ultimately, I'm not sure if we can describe this as a bug. It might be best pivoted into a feature request for a different approach. What do you all think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Inspector Controls The interface showing block settings and the controls available for each block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants