From c8887c445e409d2b07b346aa304bd30896bcbd42 Mon Sep 17 00:00:00 2001 From: Oleg Isonen Date: Wed, 19 Oct 2022 14:05:06 +0200 Subject: [PATCH] better formatting --- .../shared/css-value-input/css-value-input.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx index 3f1bbfa7fe..504bfcd149 100644 --- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx +++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx @@ -25,13 +25,12 @@ import { } from "react"; import { useUnitSelect } from "./unit-select"; -const defaultKeywords: [] = []; -const defaultValue: UnsetValue = { type: "unset", value: "" }; +const unsetValue: UnsetValue = { type: "unset", value: "" }; const isNumericString = (input: string) => String(input).trim().length !== 0 && isNaN(Number(input)) === false; -// We incrment by 10 when shift is pressed, by 0.1 when alt/option is pressed and by by 1 otherwise. +// We increment by 10 when shift is pressed, by 0.1 when alt/option is pressed and by 1 by default. const calcNumberChange = ( value: number, { altKey, shiftKey, key }: { altKey: boolean; shiftKey: boolean; key: string } @@ -87,10 +86,11 @@ const useScrub = ({ }) => { const inputRef = useRef(null); const onChangeRef = useRef(onChange); - onChangeRef.current = onChange; const onChangeCompleteRef = useRef(onChangeComplete); - onChangeCompleteRef.current = onChangeComplete; const valueRef = useRef(value); + + onChangeCompleteRef.current = onChangeComplete; + onChangeRef.current = onChange; valueRef.current = value; const type = valueRef.current.type; @@ -200,8 +200,8 @@ type CssValueInputProps = { export const CssValueInput = ({ property, - value = defaultValue, - keywords = defaultKeywords, + value = unsetValue, + keywords = [], onChange, onChangeComplete, onItemHighlight, @@ -220,7 +220,7 @@ export const CssValueInput = ({ value, itemToString: (item) => (item === null ? "" : String(item.value)), onItemSelect: (value) => { - onChangeComplete(value ?? defaultValue); + onChangeComplete(value ?? unsetValue); }, onItemHighlight, });