Skip to content

Commit

Permalink
Use Colors: Only re-detect background color when color attributes cha…
Browse files Browse the repository at this point in the history
…nge.
  • Loading branch information
epiqueras committed Nov 4, 2019
1 parent 04f656d commit 62392a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/block-editor/src/components/colors/use-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {
Expand Down Expand Up @@ -272,5 +280,5 @@ export default function __experimentalUseColors(
),
BackgroundColorDetector,
};
}, [ attributes, setAttributes, ...deps ] );
}, [ attributes, setAttributes, detectedBackgroundColorRef.current, ...deps ] );
}

0 comments on commit 62392a3

Please sign in to comment.