Skip to content

Commit

Permalink
Update MagicCodeInput.js
Browse files Browse the repository at this point in the history
  • Loading branch information
saranshbalyan-1234 authored Oct 17, 2023
1 parent bc7de34 commit 3651dfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
Expand Down

0 comments on commit 3651dfd

Please sign in to comment.