From 3651dfd702fa18262415b25725d3ce98b8e1c07d Mon Sep 17 00:00:00 2001 From: Saransh Balyan <57568571+saranshbalyan-1234@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:23:42 +0530 Subject: [PATCH] Update MagicCodeInput.js --- src/components/MagicCodeInput.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MagicCodeInput.js b/src/components/MagicCodeInput.js index fb682c0032a1..3a9cc6845194 100644 --- a/src/components/MagicCodeInput.js +++ b/src/components/MagicCodeInput.js @@ -103,7 +103,7 @@ function MagicCodeInput(props) { const [input, setInput] = useState(''); const [focusedIndex, setFocusedIndex] = useState(0); const [editIndex, setEditIndex] = useState(0); - const [wasSubmitted, setWasSubmitted] = useState(true); + const [wasSubmitted, setWasSubmitted] = useState(false); const blurMagicCodeInput = () => { inputRefs.current[editIndex].blur(); @@ -125,11 +125,11 @@ function MagicCodeInput(props) { const validateAndSubmit = () => { const numbers = decomposeString(props.value, props.maxLength); - if (!wasSubmitted || !props.shouldSubmitOnComplete || _.filter(numbers, (n) => ValidationUtils.isNumeric(n)).length !== props.maxLength || props.network.isOffline) { + if (wasSubmitted || !props.shouldSubmitOnComplete || _.filter(numbers, (n) => ValidationUtils.isNumeric(n)).length !== props.maxLength || props.network.isOffline) { return; } - if (wasSubmitted) { - setWasSubmitted(false); + if (!wasSubmitted) { + setWasSubmitted(true); } // Blurs the input and removes focus from the last input and, if it should submit // on complete, it will call the onFulfill callback.