From 1d13423b4b0e20825c5e4ffd14fcc8e3a536c865 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 13 Jul 2020 14:42:03 -0400 Subject: [PATCH] Fix color picker HSL/RGB input bug --- src/components/color-picker/color-picker.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/color-picker/color-picker.tsx b/src/components/color-picker/color-picker.tsx index 0225d2ace..0fe078713 100644 --- a/src/components/color-picker/color-picker.tsx +++ b/src/components/color-picker/color-picker.tsx @@ -420,7 +420,11 @@ export class ColorPicker { .map(val => val.trim()) .filter(val => val.length); - if (rgba[3] && rgba[3].indexOf('%') > -1) { + if (rgba.length < 4) { + rgba[3] = '1'; + } + + if (rgba[3].indexOf('%') > -1) { rgba[3] = (Number(rgba[3].replace(/%/g, '')) / 100).toString(); } @@ -434,7 +438,11 @@ export class ColorPicker { .map(val => val.trim()) .filter(val => val.length); - if (hsla[3] && hsla[3].indexOf('%') > -1) { + if (hsla.length < 4) { + hsla[3] = '1'; + } + + if (hsla[3].indexOf('%') > -1) { hsla[3] = (Number(hsla[3].replace(/%/g, '')) / 100).toString(); }