diff --git a/src/components/Button/validateSubmitShortcut/index.ts b/src/components/Button/validateSubmitShortcut/index.ts
index 29ba071c25f2f..58995252c20a6 100644
--- a/src/components/Button/validateSubmitShortcut/index.ts
+++ b/src/components/Button/validateSubmitShortcut/index.ts
@@ -1,5 +1,7 @@
import type ValidateSubmitShortcut from './types';
+const IGNORED_NODE_NAMES = ['TEXTAREA', 'INPUT'];
+
/**
* Validate if the submit shortcut should be triggered depending on the button state
*
@@ -11,7 +13,9 @@ import type ValidateSubmitShortcut from './types';
const validateSubmitShortcut: ValidateSubmitShortcut = (isDisabled, isLoading, event) => {
const eventTarget = event?.target as HTMLElement;
- if (isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA' || (eventTarget?.contentEditable === 'true' && eventTarget.ariaMultiLine)) {
+
+ // If the event target node is for an input, such as when there's a stray "Enter" event from an autocomplete input, then ignore it because it's not meant for this button
+ if (isDisabled || isLoading || IGNORED_NODE_NAMES.includes(eventTarget.nodeName) || (eventTarget?.contentEditable === 'true' && eventTarget.ariaMultiLine)) {
return false;
}
diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts
index 98f643b385e5f..0c12d920b9854 100644
--- a/src/libs/actions/Session/index.ts
+++ b/src/libs/actions/Session/index.ts
@@ -1082,6 +1082,10 @@ function toggleTwoFactorAuth(enable: boolean, twoFactorAuthCode = '') {
API.write(WRITE_COMMANDS.DISABLE_TWO_FACTOR_AUTH, params, {optimisticData, successData, failureData});
}
+function clearDisableTwoFactorAuthErrors() {
+ Onyx.merge(ONYXKEYS.ACCOUNT, {errorFields: {requiresTwoFactorAuth: null}});
+}
+
function updateAuthTokenAndOpenApp(authToken?: string, encryptedAuthToken?: string) {
// Update authToken in Onyx and in our local variables so that API requests will use the new authToken
updateSessionAuthTokens(authToken, encryptedAuthToken);
@@ -1341,4 +1345,5 @@ export {
validateUserAndGetAccessiblePolicies,
isUserOnPrivateDomain,
resetSMSDeliveryFailureStatus,
+ clearDisableTwoFactorAuthErrors,
};
diff --git a/src/pages/settings/Security/TwoFactorAuth/DisablePage.tsx b/src/pages/settings/Security/TwoFactorAuth/DisablePage.tsx
index b8a0cfa2177b5..322e1f83b5726 100644
--- a/src/pages/settings/Security/TwoFactorAuth/DisablePage.tsx
+++ b/src/pages/settings/Security/TwoFactorAuth/DisablePage.tsx
@@ -1,12 +1,15 @@
-import React, {useEffect, useRef} from 'react';
+import isEmpty from 'lodash/isEmpty';
+import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
+import ConfirmModal from '@components/ConfirmModal';
import FixedFooter from '@components/FixedFooter';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
+import {clearDisableTwoFactorAuthErrors} from '@libs/actions/Session';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
@@ -30,6 +33,13 @@ function DisablePage() {
Navigation.navigate(ROUTES.SETTINGS_2FA_DISABLED, {forceReplace: true});
}, [account?.requiresTwoFactorAuth]);
+ const closeModal = useCallback(() => {
+ clearDisableTwoFactorAuthErrors();
+
+ // Go back to the previous page because the user can't disable 2FA and this page is no longer relevant
+ Navigation.goBack();
+ }, []);
+
return (
+
);
}
diff --git a/src/types/onyx/Account.ts b/src/types/onyx/Account.ts
index 97fa83dc86702..e095815771839 100644
--- a/src/types/onyx/Account.ts
+++ b/src/types/onyx/Account.ts
@@ -137,6 +137,9 @@ type Account = {
/** Authentication failure errors */
errors?: OnyxCommon.Errors | null;
+ /** Errors related to specific account fields */
+ errorFields?: OnyxCommon.ErrorFields;
+
/** Authentication success message */
success?: string;