Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,15 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
blurOnSubmit={account.validated === false}
scrollPageToTop={signInPageLayoutRef.current && signInPageLayoutRef.current.scrollPageToTop}
/>
{shouldShowValidateCodeForm && (
<ValidateCodeForm
isVisible={!shouldShowAnotherLoginPageOpenedMessage}
isUsingRecoveryCode={isUsingRecoveryCode}
setIsUsingRecoveryCode={setIsUsingRecoveryCode}
/>
)}
{!shouldShowAnotherLoginPageOpenedMessage && (
<>
{shouldShowValidateCodeForm && (
<ValidateCodeForm
isUsingRecoveryCode={isUsingRecoveryCode}
setIsUsingRecoveryCode={setIsUsingRecoveryCode}
/>
)}
{shouldShowUnlinkLoginForm && <UnlinkLoginForm />}
{shouldShowChooseSSOOrMagicCode && <ChooseSSOOrMagicCode setIsUsingMagicCode={setIsUsingMagicCode} />}
{shouldShowEmailDeliveryFailurePage && <EmailDeliveryFailurePage />}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useRef, useState} from 'react';
Expand All @@ -13,6 +14,7 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withToggleVisibilityView from '@components/withToggleVisibilityView';
import usePrevious from '@hooks/usePrevious';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
Expand Down Expand Up @@ -85,6 +87,7 @@ function BaseValidateCodeForm(props) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const isFocused = useIsFocused();
const [formError, setFormError] = useState({});
const [validateCode, setValidateCode] = useState(props.credentials.validateCode || '');
const [twoFactorAuthCode, setTwoFactorAuthCode] = useState('');
Expand Down Expand Up @@ -113,11 +116,11 @@ function BaseValidateCodeForm(props) {
}, [props.account.isLoading, props.session.autoAuthState, hasError]);

useEffect(() => {
if (!inputValidateCodeRef.current || !canFocusInputOnScreenFocus()) {
if (!inputValidateCodeRef.current || !canFocusInputOnScreenFocus() || !props.isVisible || !isFocused) {
return;
}
inputValidateCodeRef.current.focus();
}, []);
}, [props.isVisible, isFocused]);

useEffect(() => {
if (prevValidateCode || !props.credentials.validateCode) {
Expand Down Expand Up @@ -431,4 +434,5 @@ export default compose(
session: {key: ONYXKEYS.SESSION},
}),
withNetwork(),
withToggleVisibilityView,
)(BaseValidateCodeForm);