From 62392a36104a1d4d2cef630ec505b436bf909fdd Mon Sep 17 00:00:00 2001 From: epiqueras Date: Mon, 4 Nov 2019 14:56:38 -0800 Subject: [PATCH] Use Colors: Only re-detect background color when color attributes change. --- .../block-editor/src/components/colors/use-colors.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/colors/use-colors.js b/packages/block-editor/src/components/colors/use-colors.js index b8d9d18f2a71a..2e423fdbad8c4 100644 --- a/packages/block-editor/src/components/colors/use-colors.js +++ b/packages/block-editor/src/components/colors/use-colors.js @@ -199,7 +199,15 @@ export default function __experimentalUseColors( detectedBackgroundColorRef.current = backgroundColor; return { backgroundColor }; } )( () => <> ), - [ attributes ] + [ + colorConfigs.reduce( + ( acc, colorConfig ) => + `${ acc } | ${ attributes[ colorConfig.name ] } | ${ + attributes[ camelCase( `custom ${ colorConfig.name }` ) ] + }`, + '' + ), + ] ); return useMemo( () => { @@ -272,5 +280,5 @@ export default function __experimentalUseColors( ), BackgroundColorDetector, }; - }, [ attributes, setAttributes, ...deps ] ); + }, [ attributes, setAttributes, detectedBackgroundColorRef.current, ...deps ] ); }