From 6273d5652448329107f8d480362019696e12ad1a Mon Sep 17 00:00:00 2001 From: zsviczian Date: Thu, 22 Dec 2022 13:53:49 +0100 Subject: [PATCH] fix: ColorPicker getColor (#5949) Co-authored-by: dwelle --- src/components/ColorPicker.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx index 03ab4a5be..cb05cf446 100644 --- a/src/components/ColorPicker.tsx +++ b/src/components/ColorPicker.tsx @@ -66,10 +66,13 @@ const getColor = (color: string): string | null => { return color; } - return isValidColor(color) - ? color - : isValidColor(`#${color}`) + // testing for `#` first fixes a bug on Electron (more specfically, an + // Obsidian popout window), where a hex color without `#` is (incorrectly) + // considered valid + return isValidColor(`#${color}`) ? `#${color}` + : isValidColor(color) + ? color : null; };