Skip to content

Commit

Permalink
Use Colors: Pass down refs to contrast checker to avoid stale values.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Nov 26, 2019
1 parent a537bc0 commit 45c81d4
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions packages/block-editor/src/components/colors/use-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const ColorPanel = ( {
colorSettings,
colorPanelProps,
contrastCheckers,
detectedBackgroundColor,
detectedColor,
detectedBackgroundColorRef,
detectedColorRef,
panelChildren,
} ) => (
<PanelColorSettings
Expand All @@ -64,12 +64,12 @@ const ColorPanel = ( {
backgroundColor = resolveContrastCheckerColor(
backgroundColor,
colorSettings,
detectedBackgroundColor
detectedBackgroundColorRef.current
);
textColor = resolveContrastCheckerColor(
textColor,
colorSettings,
detectedColor
detectedColorRef.current
);
return (
<ContrastChecker
Expand All @@ -85,12 +85,12 @@ const ColorPanel = ( {
backgroundColor = resolveContrastCheckerColor(
backgroundColor || value,
colorSettings,
detectedBackgroundColor
detectedBackgroundColorRef.current
);
textColor = resolveContrastCheckerColor(
textColor || value,
colorSettings,
detectedColor
detectedColorRef.current
);
return (
<ContrastChecker
Expand Down Expand Up @@ -330,8 +330,8 @@ export default function __experimentalUseColors(
colorSettings,
colorPanelProps,
contrastCheckers,
detectedBackgroundColor: detectedBackgroundColorRef.current,
detectedColor: detectedColorRef.current,
detectedBackgroundColorRef,
detectedColorRef,
panelChildren,
};
return {
Expand All @@ -342,11 +342,5 @@ export default function __experimentalUseColors(
),
ColorDetector,
};
}, [
attributes,
setAttributes,
detectedBackgroundColorRef.current,
detectedColorRef.current,
...deps,
] );
}, [ attributes, setAttributes, ...deps ] );
}

0 comments on commit 45c81d4

Please sign in to comment.