From 722dcdd88face3724c77d23bc36a00524e552551 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Thu, 26 Mar 2026 13:52:30 +0100 Subject: fix: resolve typescript/lint errors --- apps/web/src/components/ui/number-field.tsx | 47 ++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'apps/web/src/components/ui') diff --git a/apps/web/src/components/ui/number-field.tsx b/apps/web/src/components/ui/number-field.tsx index 18d71591..acedff10 100644 --- a/apps/web/src/components/ui/number-field.tsx +++ b/apps/web/src/components/ui/number-field.tsx @@ -134,20 +134,28 @@ function NumberField({ ref, ...props }: NumberFieldProps & { ref?: React.Ref }) { - const iconRef = useRef(null); + const iconRef = useRef(null); const inputRef = useRef(null); const ghostRef = useRef(null); const startValueRef = useRef(0); const cumulativeDeltaRef = useRef(0); const [isInputFocused, setIsInputFocused] = useState(false); const [suffixLeft, setSuffixLeft] = useState(0); + const ghostValue = Array.isArray(value) ? value.join(", ") : String(value ?? ""); useLayoutEffect(() => { - if (!suffix || !ghostRef.current || !inputRef.current) return; + if (!suffix) { + setSuffixLeft(0); + return; + } + if (!ghostRef.current || !inputRef.current) return; + if (ghostRef.current.textContent !== ghostValue) { + ghostRef.current.textContent = ghostValue; + } const paddingLeft = parseFloat(getComputedStyle(inputRef.current).paddingLeft) || 0; setSuffixLeft(paddingLeft + ghostRef.current.offsetWidth); - }, [value, suffix]); + }, [ghostValue, suffix]); const { containerRef: wrapperRef } = useFocusLock({ isActive: isInputFocused, @@ -243,19 +251,24 @@ function NumberField({ className, )} > - {icon && ( - event.preventDefault() : undefined} - onPointerDown={canScrub ? handleIconPointerDown : undefined} - > - {icon} - - )} + {icon && + (canScrub ? ( + + ) : ( + + {icon} + + ))}