Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2FA Input field not focused on mobile #20891

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ function MagicCodeInput(props) {
setFocusedIndex(0);
inputRefs.current[0].focus();
},
resetFocus() {
setInput('');
setFocusedIndex(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of below 2 lines we can directly call focus() to avoid duplicate code

Copy link
Contributor Author

@WikusKriek WikusKriek Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@abdulrahuman5196 It will look something like this then. I am not able to call one handler through the other in useImperativeHandle. Or in the same component without extracting to an outside function like blur.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WikusKriek This seems to be fine IMO if we are unable to call within imperative functions, compared to having duplicate code. We can name it as focusMagicCodeInput similar to blur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes.

inputRefs.current[0].focus();
},
clear() {
setInput('');
setFocusedIndex(0);
Expand Down
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