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

Add all color palettes to select from editor panel #65148

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@ import { useSettings } from '../use-settings';

export default createHigherOrderComponent( ( WrappedComponent ) => {
return ( props ) => {
const [ colorsFeature, enableCustomColors ] = useSettings(
'color.palette',
'color.custom'
// Get the default colors, theme colors, and custom colors
const [
defaultColors,
themeColors,
customColors,
enableCustomColors,
enableDefaultColors,
] = useSettings(
'color.palette.default',
'color.palette.theme',
'color.palette.custom',
'color.custom',
'color.defaultPalette'
);
const {
colors = colorsFeature,
disableCustomColors = ! enableCustomColors,
} = props;

const _colors = enableDefaultColors
? [
...( themeColors || [] ),
...( defaultColors || [] ),
...( customColors || [] ),
]
: [ ...( themeColors || [] ), ...( customColors || [] ) ];

const { colors = _colors, disableCustomColors = ! enableCustomColors } =
props;

const hasColorsToChoose =
( colors && colors.length > 0 ) || ! disableCustomColors;
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ describe( 'Cover block', () => {
describe( 'when colors are disabled', () => {
test( 'does not render overlay control', async () => {
await setup( undefined, true, disabledColorSettings );
await createAndSelectBlock();
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByRole( 'tab', { name: 'Styles' } )
);
Expand All @@ -350,7 +350,7 @@ describe( 'Cover block', () => {
} );
test( 'does not render opacity control', async () => {
await setup( undefined, true, disabledColorSettings );
await createAndSelectBlock();
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByRole( 'tab', { name: 'Styles' } )
);
Expand Down
Loading