From 09fb933bf3671635c982276792611b1b1a5e4219 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Tue, 4 Jun 2024 15:58:49 +0200 Subject: [PATCH] Set minimum size of text inputs depending on handle (#2938) --- src/renderer/components/inputs/TextInput.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/inputs/TextInput.tsx b/src/renderer/components/inputs/TextInput.tsx index beedd5726..90b77440b 100644 --- a/src/renderer/components/inputs/TextInput.tsx +++ b/src/renderer/components/inputs/TextInput.tsx @@ -14,7 +14,8 @@ import { DragHandleSVG } from '../CustomIcons'; import { AutoLabel } from './InputContainer'; import { InputProps } from './props'; -const DEFAULT_SIZE = { width: 222, height: 80 } as const; +const DEFAULT_SIZE_WITHOUT_HANDLE = { width: 222, height: 80 } as const; +const DEFAULT_SIZE = { width: 214, height: 80 } as const; const invalidRegexCache = new Map(); const getInvalidRegex = (pattern: string): RegExp | undefined => { @@ -165,22 +166,23 @@ export const TextInput = memo( )); // size + const defaultSize = input.hasHandle ? DEFAULT_SIZE : DEFAULT_SIZE_WITHOUT_HANDLE; useEffect(() => { if (!size) { - setSize(DEFAULT_SIZE); + setSize(defaultSize); } - }, [size, setSize]); + }, [size, setSize, defaultSize]); const zoom = useContextSelector(GlobalVolatileContext, (c) => c.zoom); - const startSize = useRef(size ?? DEFAULT_SIZE); + const startSize = useRef(size ?? defaultSize); let inputElement; if (multiline) { inputElement = ( { @@ -220,7 +222,7 @@ export const TextInput = memo( } }} onResizeStart={() => { - startSize.current = size ?? DEFAULT_SIZE; + startSize.current = size ?? defaultSize; }} >