浏览代码

fix: ColorPicker getColor (#5949)

Co-authored-by: dwelle <luzar.david@gmail.com>
zsviczian 2 年之前
父节点
当前提交
6273d56524
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/components/ColorPicker.tsx

+ 6 - 3
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;
 };