Skip to content

Commit

Permalink
Merge pull request #20891 from WikusKriek/19711-2FA-Input-field-not-f…
Browse files Browse the repository at this point in the history
…ocused-on-mobile

2FA Input field not focused on mobile
  • Loading branch information
luacmartins authored Jun 20, 2023
2 parents 5b7f39b + 7f8907f commit 93042af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,18 @@ function MagicCodeInput(props) {
setFocusedIndex(undefined);
};

const focusMagicCodeInput = () => {
setFocusedIndex(0);
inputRefs.current[0].focus();
};

useImperativeHandle(props.innerRef, () => ({
focus() {
setFocusedIndex(0);
inputRefs.current[0].focus();
focusMagicCodeInput();
},
resetFocus() {
setInput('');
focusMagicCodeInput();
},
clear() {
setInput('');
Expand Down
2 changes: 1 addition & 1 deletion src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function BaseValidateCodeForm(props) {
if (!input2FARef.current || prevRequiresTwoFactorAuth || !props.account.requiresTwoFactorAuth) {
return;
}
input2FARef.current.focus();
input2FARef.current.resetFocus();
}, [props.account.requiresTwoFactorAuth, prevRequiresTwoFactorAuth]);

useEffect(() => {
Expand Down

0 comments on commit 93042af

Please sign in to comment.