fix: ColorPicker getColor (#5949)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
zsviczian 2022-12-22 13:53:49 +01:00 committed by GitHub
parent 7e135c4e22
commit 6273d56524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -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;
};