diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index f46afbb1d18985..22a08c2f0dd08c 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Bug Fix + +- `ColorPalette`: show "Clear" button even when colors array is empty ([#46001](https://github.com/WordPress/gutenberg/pull/46001)). + ### Enhancements - `TabPanel`: Add ability to set icon only tab buttons ([#45005](https://github.com/WordPress/gutenberg/pull/45005)). diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 4c36a8e56df83c..5146e3c8581988 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -84,10 +84,6 @@ function SinglePalette( { } ); }, [ colors, value, onChange, clearColor ] ); - if ( colors.length === 0 ) { - return null; - } - return ( = { title: 'Components/ColorPalette', @@ -43,10 +42,7 @@ const Template: ComponentStory< typeof ColorPalette > = ( { onChange, ...args } ) => { - const firstColor = - ( args.colors as ColorObject[] )[ 0 ].color || - ( args.colors as PaletteObject[] )[ 0 ].colors[ 0 ].color; - const [ color, setColor ] = useState< string | undefined >( firstColor ); + const [ color, setColor ] = useState< string | undefined >(); return ( diff --git a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap index 573ff940ebf0db..d4ea4015c639fa 100644 --- a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap @@ -63,10 +63,10 @@ exports[`ColorPalette should allow disabling custom color picker 1`] = ` class="components-circular-option-picker__option-wrapper" >