From 2a5b1b81568c6191ca7817bc91ea55b1db2c536f Mon Sep 17 00:00:00 2001 From: eliza Date: Wed, 7 Feb 2024 16:50:11 -0800 Subject: [PATCH] refactor and simplify --- .../src/components/color-picker/color-picker.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/calcite-components/src/components/color-picker/color-picker.tsx b/packages/calcite-components/src/components/color-picker/color-picker.tsx index 9c2d18a8437..125a9c4def7 100644 --- a/packages/calcite-components/src/components/color-picker/color-picker.tsx +++ b/packages/calcite-components/src/components/color-picker/color-picker.tsx @@ -1408,7 +1408,7 @@ export class ColorPicker const pattern = context.createPattern(this.getCheckeredBackgroundPattern(), "repeat"); - if (color.alpha() < 1) { + if (color.alpha() < 1 && applyAlpha) { context.beginPath(); context.arc(x, y, radius - 3, startAngle, endAngle); context.fillStyle = pattern; @@ -1419,9 +1419,8 @@ export class ColorPicker context.beginPath(); context.arc(x, y, radius - 3, startAngle, endAngle); - applyAlpha - ? (context.fillStyle = color.rgb().alpha(color.alpha()).string()) - : (context.fillStyle = color.rgb().alpha(1).string()); + const alpha = applyAlpha ? color.alpha() : 1; + context.fillStyle = color.rgb().alpha(alpha).string(); context.fill(); context.globalCompositeOperation = "source-over";