From e66d443a97bcd15d70e30a9d968fc09bff037672 Mon Sep 17 00:00:00 2001 From: yougotwill Date: Wed, 31 Jul 2024 15:32:06 +1000 Subject: [PATCH] fix: reset input color after error if the value changes --- ts/components/inputs/SessionInput.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/components/inputs/SessionInput.tsx b/ts/components/inputs/SessionInput.tsx index f52ec154f..699435cd4 100644 --- a/ts/components/inputs/SessionInput.tsx +++ b/ts/components/inputs/SessionInput.tsx @@ -277,6 +277,7 @@ export const SessionInput = (props: Props) => { } = props; const [inputValue, setInputValue] = useState(''); const [errorString, setErrorString] = useState(''); + const [textErrorStyle, setTextErrorStyle] = useState(false); const [forceShow, setForceShow] = useState(false); const correctType = forceShow ? 'text' : type; @@ -288,6 +289,7 @@ export const SessionInput = (props: Props) => { e.preventDefault(); const val = e.target.value; setInputValue(val); + setTextErrorStyle(false); if (onValueChanged) { onValueChanged(val); } @@ -332,7 +334,7 @@ export const SessionInput = (props: Props) => { const containerProps = { noValue: isEmpty(value), - error: Boolean(error), + error: textErrorStyle, centerText, textSize, monospaced, @@ -342,6 +344,7 @@ export const SessionInput = (props: Props) => { useEffect(() => { if (error && !isEmpty(error) && !isEqual(error, errorString)) { setErrorString(error); + setTextErrorStyle(!!error); } }, [error, errorString]);