WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

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

Open madhusudhand opened 7 months ago

madhusudhand commented 7 months ago

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

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

annezazu commented 7 months ago

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 commented 7 months ago

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

https://github.com/WordPress/gutenberg/blob/91ea8fa5862f02bb6e885b98a20dbc627e08a025/packages/block-editor/src/hooks/border.js#L237-L242

~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.

madhusudhand commented 7 months ago

@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

https://github.com/WordPress/gutenberg/blob/0f689f9af5b28ba53f7047a346882296329e13c6/packages/block-editor/src/components/global-styles/border-panel.js#L230

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

https://github.com/WordPress/gutenberg/blob/0f689f9af5b28ba53f7047a346882296329e13c6/packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js#L15

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

I don't understand the reason behind this.

t-hamano commented 7 months ago

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

Yes, I'm also wondering why this happens 🤔

madhusudhand commented 6 months ago

@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 commented 6 months ago

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.

madhusudhand commented 5 months ago

This is issue when the support is enabled in classic themes in #60373

ellatrix commented 3 months ago

This is not a regression, must be punted to 6.7