From 108fe9836e32c54179a9d3b9beb1f6111528dc72 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 22 Aug 2023 18:10:46 -0700 Subject: [PATCH] Do not focus the last magic code input if it is empty --- src/components/MagicCodeInput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/MagicCodeInput.js b/src/components/MagicCodeInput.js index 5dba1c9c1b20..d6e539340274 100644 --- a/src/components/MagicCodeInput.js +++ b/src/components/MagicCodeInput.js @@ -137,9 +137,13 @@ function MagicCodeInput(props) { return; } + if (props.value.length !== props.maxLength) { + return; + } + // Focus the last input if an error occurred to allow for corrections inputRefs.current[props.maxLength - 1].focus(); - }, [props.hasError, props.maxLength]); + }, [props.hasError, props.maxLength, props.value]); useEffect(() => { validateAndSubmit(props.value);