WordPress / gutenberg

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

Block Editor Color Palette: Only custom color palettes are displayed #64857

Open t-hamano opened 2 weeks ago

t-hamano commented 2 weeks ago

Description

If the custom color palette is defined in the global styles, the color palette in the block editor package only shows that custom color palette.

Note that I'm talking about the ColorPalette component in the block editor package, not the ColorPalette component in the components package.

This issue can be seen in color inline formatting and Cover block placeholder. From what I've tested in Playground, this problem appears to have been occurring since at least WP6.3. As I recall, all palettes - theme, default, and custom - were displayed in the past.

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

Cover block and text color format. Only custom colors are shown:

custom-color

If no custom color is defined, the theme color is displayed:

image

Like color block support, it should display all three colors default, theme, and custom:

image

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

EddyBoels commented 2 weeks ago

Same here. If you create a custom colour in the styles, then in a text block, the highlight option will only offer this colour without the basic palette.

t-hamano commented 2 weeks ago

I've confirmed that this issue has been occurring since at least WP 6.0.

rohitmathur-7 commented 2 weeks ago

Hii @t-hamano , I was also checking this issue recently and found this related Issue from February: https://github.com/WordPress/gutenberg/issues/59171

Here it is mentioned that we are getting the custom colors from this code:

$editor_settings['__experimentalFeatures'] = wp_get_global_settings();
// These settings may need to be updated based on data coming from theme.json sources.
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
$colors_by_origin          = $editor_settings['__experimentalFeatures']['color']['palette'];
$editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
    $colors_by_origin['custom'] : (
        isset( $colors_by_origin['theme'] ) ?
            $colors_by_origin['theme'] :
            $colors_by_origin['default']
    );
}

But when I was checking this in my local I modified this code to set the value of $editor_settings['colors'] as $colors_by_origin['theme'] for testing but still I was getting the custom colors only 🤔 .