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

Shadow: tools panel label is set to Shadow instead of Border & Shadow #60192

Open
madhusudhand opened this issue Mar 26, 2024 · 6 comments
Open
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended

Comments

@madhusudhand
Copy link
Contributor

madhusudhand commented Mar 26, 2024

Description

When defaultPresets is set to true in classic themes via functions.php

Issue: Label is set to Shadow even though there exists radius control.
Expectation: When Border and shadow controls both present label should be set to Border & Shadow

image

Step-by-step reproduction instructions

  1. Enable a classic theme

Enable defaultPresets by adding following code to functions.php

add_filter( 'wp_theme_json_data_default', 'themeslug_theme_json_data_default' );

function themeslug_theme_json_data_default( $theme_json ) {
       $data = [
               'version'  => 2,
               'settings' => [
                      'shadow' => [
                              'defaultPresets' => true,
                      ]
               ]
      ];
      return $theme_json->update_with( $data );
}
  1. Edit a post and add a button block
  2. Navigate to Border tools panel
  3. Observe that panel label is set to 'Shadow' instead of 'Border & Shadow'

Screenshots, screen recording, code snippet

No response

Environment info

  • Wordpress 6.5
  • Gutenberg latest

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

@madhusudhand madhusudhand added the [Type] Bug An existing feature does not function as intended label Mar 26, 2024
@madhusudhand madhusudhand changed the title Shadow: tools panel label is sometimes set to Shadow instead of Border & Shadow Shadow: tools panel label is set to Shadow instead of Border & Shadow Mar 26, 2024
@annezazu annezazu added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label Mar 26, 2024
@annezazu
Copy link
Contributor

Going to add this to the 6.5.1 section for consideration since this impacts a feature coming to 6.5 but is minor in the grand scheme of things.

@t-hamano
Copy link
Contributor

t-hamano commented Apr 1, 2024

My guess is that it's because we're directly overriding the hook's props here.

hasBorderControl =
controls?.hasBorderColor ||
controls?.hasBorderStyle ||
controls?.hasBorderWidth ||
controls?.hasBorderRadius;
hasShadowControl = controls?.hasShadow;

I would like to submit a PR soon.

Update: It seems that the above is not the cause. I'll continue researching, but I'd be happy if anyone can find a solution to this problem.

@t-hamano t-hamano assigned t-hamano and unassigned t-hamano Apr 1, 2024
@madhusudhand
Copy link
Contributor Author

madhusudhand commented Apr 2, 2024

@t-hamano

As I understand the function useBorderPanelLabel uses const settings = useBlockSettings( blockName ); to get block settings and then returns the right label.

But, the settings object is being returned differently from different instances.

for comparison

from global styles returns settings.border.radius: true,
where as

const borderPanelLabel = useBorderPanelLabel( { blockName } );

from block inspector-controls returns settings.border.radius: false.

I don't understand the reason behind this.

@t-hamano
Copy link
Contributor

t-hamano commented Apr 3, 2024

But, the settings object is being returned differently from different instances.

Yes, I'm also wondering why this happens 🤔

@madhusudhand
Copy link
Contributor Author

@annezazu since we reverted a change in #60204, shadows in classic themes aren't enabled/supported yet and it's no longer a bug in 6.5
This will be address in WordPress 6.6 along with support for classic themes.

@creativecoder
Copy link
Contributor

shadows in classic themes aren't enabled/supported yet and it's no longer a bug in 6.5

Given this, I'm going to remove this issue from the 6.5.x board, since we no longer plan to address it in a minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Bug An existing feature does not function as intended
Projects
Status: 🐛 Punted to 6.5.1
Status: 📥 Todo
Development

No branches or pull requests

4 participants