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

Fix pressing back button doesn't close the validate code modal when keyboard is shown #53435

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
10 changes: 8 additions & 2 deletions src/components/HeaderPageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useMemo} from 'react';
import type {ReactNode} from 'react';
import {View} from 'react-native';
import type {StyleProp, ViewStyle} from 'react-native';
import type {ScrollViewProps, StyleProp, ViewStyle} from 'react-native';
import useNetwork from '@hooks/useNetwork';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
Expand Down Expand Up @@ -44,6 +44,8 @@ type HeaderPageLayoutProps = ChildrenProps &

/** Whether or not to show the offline indicator */
shouldShowOfflineIndicatorInWideScreen?: boolean;

keyboardShouldPersistTaps?: ScrollViewProps['keyboardShouldPersistTaps'];
};
function HeaderPageLayout({
backgroundColor,
Expand All @@ -56,6 +58,7 @@ function HeaderPageLayout({
headerContent,
shouldShowOfflineIndicatorInWideScreen = false,
testID,
keyboardShouldPersistTaps,
...rest
}: HeaderPageLayoutProps) {
const theme = useTheme();
Expand Down Expand Up @@ -98,7 +101,10 @@ function HeaderPageLayout({
<View style={[shouldUseNarrowLayout ? styles.flex1 : styles.flex3, appBGColor]} />
</View>
)}
<ScrollView contentContainerStyle={[safeAreaPaddingBottomStyle, style, scrollViewContainerStyles]}>
<ScrollView
contentContainerStyle={[safeAreaPaddingBottomStyle, style, scrollViewContainerStyles]}
keyboardShouldPersistTaps={keyboardShouldPersistTaps}
>
{!Browser.isSafari() && <View style={styles.overscrollSpacer(backgroundColor ?? theme.appBG, windowHeight)} />}
<View style={[styles.alignItemsCenter, styles.justifyContentEnd, StyleUtils.getBackgroundColorStyle(backgroundColor ?? theme.appBG), headerContainerStyles]}>
{headerContent}
Expand Down
26 changes: 13 additions & 13 deletions src/pages/ReimbursementAccount/BankAccountStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,21 @@ function BankAccountStep({
/>
</View>
</PressableWithoutFeedback>
<ValidateCodeActionModal
title={translate('contacts.validateAccount')}
descriptionPrimary={translate('contacts.featureRequiresValidate')}
descriptionSecondary={translate('contacts.enterMagicCode', {contactMethod})}
isVisible={!!isValidateCodeActionModalVisible}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
validatePendingAction={loginData?.pendingFields?.validateCodeSent}
sendValidateCode={() => User.requestValidateCodeAction()}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onClose={() => toggleValidateCodeActionModal?.(false)}
/>
</View>
</ScrollView>
<ValidateCodeActionModal
title={translate('contacts.validateAccount')}
descriptionPrimary={translate('contacts.featureRequiresValidate')}
descriptionSecondary={translate('contacts.enterMagicCode', {contactMethod})}
isVisible={!!isValidateCodeActionModalVisible}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
validatePendingAction={loginData?.pendingFields?.validateCodeSent}
sendValidateCode={() => User.requestValidateCodeAction()}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onClose={() => toggleValidateCodeActionModal?.(false)}
/>
</View>
</ScreenWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) {
testID={ConfirmDelegatePage.displayName}
footer={submitButton}
childrenContainerStyles={[styles.pt3, styles.gap6]}
keyboardShouldPersistTaps="handled"
>
<Text style={[styles.ph5]}>{translate('delegate.confirmCopilot')}</Text>
<MenuItem
Expand Down
34 changes: 17 additions & 17 deletions src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,24 @@ function CodesStep({backTo}: CodesStepProps) {
}}
/>
</FixedFooter>
<ValidateCodeActionModal
title={translate('contacts.validateAccount')}
descriptionPrimary={translate('contacts.featureRequiresValidate')}
descriptionSecondary={translate('contacts.enterMagicCode', {contactMethod})}
isVisible={isValidateModalVisible}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
validatePendingAction={loginData?.pendingFields?.validateCodeSent}
sendValidateCode={() => User.requestValidateCodeAction()}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode, true)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onModalHide={() => {}}
onClose={() => {
setIsValidateModalVisible(false);
TwoFactorAuthActions.quitAndNavigateBack(backTo);
}}
/>
</ScrollView>
<ValidateCodeActionModal
title={translate('contacts.validateAccount')}
descriptionPrimary={translate('contacts.featureRequiresValidate')}
descriptionSecondary={translate('contacts.enterMagicCode', {contactMethod})}
isVisible={isValidateModalVisible}
hasMagicCodeBeenSent={hasMagicCodeBeenSent}
validatePendingAction={loginData?.pendingFields?.validateCodeSent}
sendValidateCode={() => User.requestValidateCodeAction()}
handleSubmitForm={(validateCode) => User.validateSecondaryLogin(loginList, contactMethod, validateCode, true)}
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : ErrorUtils.getLatestErrorField(loginData, 'validateCodeSent')}
clearError={() => User.clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
onModalHide={() => {}}
onClose={() => {
setIsValidateModalVisible(false);
TwoFactorAuthActions.quitAndNavigateBack(backTo);
}}
/>
</StepWrapper>
);
}
Expand Down
Loading