Skip to content

Commit

Permalink
Fix: useColors crash when themes remove the color pallete
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Nov 6, 2019
1 parent 59da6ed commit e22ba17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/colors/use-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ]
Expand Down

0 comments on commit e22ba17

Please sign in to comment.