From e22ba173386fe8d7b54ca70790f048cd0519f9b8 Mon Sep 17 00:00:00 2001 From: Jorge Date: Tue, 5 Nov 2019 12:57:23 +0000 Subject: [PATCH] Fix: useColors crash when themes remove the color pallete --- packages/block-editor/src/components/colors/use-colors.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/colors/use-colors.js b/packages/block-editor/src/components/colors/use-colors.js index d69ee1bdbadf9..6cc12ae45f321 100644 --- a/packages/block-editor/src/components/colors/use-colors.js +++ b/packages/block-editor/src/components/colors/use-colors.js @@ -30,6 +30,8 @@ import ContrastChecker from '../contrast-checker'; import InspectorControls from '../inspector-controls'; import { useBlockEditContext } from '../block-edit'; +const DEFAULT_COLORS = []; + const ColorPanel = ( { title, colorSettings, @@ -79,9 +81,10 @@ export default function __experimentalUseColors( const { attributes, settingsColors } = useSelect( ( select ) => { const { getBlockAttributes, getSettings } = select( 'core/block-editor' ); + const colors = getSettings().colors; return { attributes: getBlockAttributes( clientId ), - settingsColors: getSettings().colors, + settingsColors: ! colors || colors === true ? DEFAULT_COLORS : colors, }; }, [ clientId ]