fix: reset input color after error if the value changes

pull/3137/head
yougotwill 1 year ago
parent 81d6b18689
commit e66d443a97

@ -277,6 +277,7 @@ export const SessionInput = (props: Props) => {
} = props; } = props;
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const [errorString, setErrorString] = useState(''); const [errorString, setErrorString] = useState('');
const [textErrorStyle, setTextErrorStyle] = useState(false);
const [forceShow, setForceShow] = useState(false); const [forceShow, setForceShow] = useState(false);
const correctType = forceShow ? 'text' : type; const correctType = forceShow ? 'text' : type;
@ -288,6 +289,7 @@ export const SessionInput = (props: Props) => {
e.preventDefault(); e.preventDefault();
const val = e.target.value; const val = e.target.value;
setInputValue(val); setInputValue(val);
setTextErrorStyle(false);
if (onValueChanged) { if (onValueChanged) {
onValueChanged(val); onValueChanged(val);
} }
@ -332,7 +334,7 @@ export const SessionInput = (props: Props) => {
const containerProps = { const containerProps = {
noValue: isEmpty(value), noValue: isEmpty(value),
error: Boolean(error), error: textErrorStyle,
centerText, centerText,
textSize, textSize,
monospaced, monospaced,
@ -342,6 +344,7 @@ export const SessionInput = (props: Props) => {
useEffect(() => { useEffect(() => {
if (error && !isEmpty(error) && !isEqual(error, errorString)) { if (error && !isEmpty(error) && !isEqual(error, errorString)) {
setErrorString(error); setErrorString(error);
setTextErrorStyle(!!error);
} }
}, [error, errorString]); }, [error, errorString]);

Loading…
Cancel
Save