Skip to content

Commit

Permalink
fix: color format warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and logseq-cldwalker committed May 30, 2023
1 parent c87377f commit 2e9cd3a
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -34,6 +34,10 @@ export function ColorInput({
)
}

function isHexColor(color: string) {
return /^#(?:[0-9a-f]{3}){1,2}$/i.test(color)
}

const handleChangeDebounced = React.useMemo(() => {
let latestValue = ''

Expand Down Expand Up @@ -78,7 +82,7 @@ export function ColorInput({
className="color-input cursor-pointer"
id="tl-custom-color-input"
type="color"
value={color}
value={isHexColor(color) ? color : "#000000"}
onChange={handleChangeDebounced}
style={{ opacity: isBuiltInColor(color) ? 0 : 1 }}
{...rest}
Expand Down

0 comments on commit 2e9cd3a

Please sign in to comment.