diff --git a/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx b/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx index 97558cc83c..dfb6ba88f5 100644 --- a/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/inputs/ColorInput.tsx @@ -7,15 +7,22 @@ interface ColorInputProps extends React.InputHTMLAttributes { export function ColorInput({ label, value, onChange, ...rest }: ColorInputProps) { const ref = React.useRef(null) const [computedValue, setComputedValue] = React.useState(value) - + let varName: string | undefined // TODO: listen to theme change? if (value?.toString().startsWith('var') && ref.current) { - const varName = /var\((.*)\)/.exec(value.toString())?.[1] + varName = /var\((.*)\)/.exec(value.toString())?.[1] if (varName) { - setComputedValue(getComputedStyle(ref.current).getPropertyValue(varName).trim()) + const newValue = getComputedStyle(ref.current).getPropertyValue(varName).trim(); + if (newValue !== computedValue) { + setComputedValue(newValue) + } } } + if (varName) { + return null + } + return (
@@ -25,7 +32,7 @@ export function ColorInput({ label, value, onChange, ...rest }: ColorInputProps) name={`color-${label}`} type="color" value={computedValue} - onChange={(e) => { + onChange={e => { setComputedValue(e.target.value) onChange?.(e) }}