-
Notifications
You must be signed in to change notification settings - Fork 3k
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:blank page appears in validate code form page #55588
Open
jacobkim9881
wants to merge
21
commits into
Expensify:main
Choose a base branch
from
jacobkim9881:m53884
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+121
−19
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6373c37
fix:blank page appears in validate code form page
jacobkim9881 172c7b0
lint: fixed ! assertion error
jacobkim9881 c4e944f
pulled original/main
jacobkim9881 6232476
lint assertion err fixed
jacobkim9881 d216e60
lint disabled prop spreading
jacobkim9881 217ac60
Revert "pulled original/main"
jacobkim9881 622df4f
comment type for ref
jacobkim9881 9f1f207
should resolve() if container is undefined
jacobkim9881 5493c6b
comment about focus trap for animation
jacobkim9881 dd436e9
fix: clicking header back err occurs
jacobkim9881 a404826
clear error only after closing the modal
jacobkim9881 6640264
Merge branch 'main' of https://github.com/Expensify/App into m53884
jacobkim9881 6a12518
lint fixed
jacobkim9881 3f12bb5
Revert "lint fixed"
jacobkim9881 433778f
lint fixed
jacobkim9881 c001758
Merge branch 'main' of https://github.com/Expensify/App into m53884
jacobkim9881 72e88b7
Merge branch 'main' of https://github.com/Expensify/App into m53884
jacobkim9881 0afd14a
moved isVisible in the validate code form
jacobkim9881 9b7b20d
Merge branch 'main' of https://github.com/Expensify/App into m53884
jacobkim9881 c19c2af
hide menu items while sliding out of validate page
jacobkim9881 0c12b86
Revert "hide menu items while sliding out of validate page"
jacobkim9881 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, {forwardRef, useEffect, useRef} from 'react'; | ||
import type {ForwardedRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import Text from './Text'; | ||
import type {ValidateCodeActionModalProps} from './ValidateCodeActionModal/type'; | ||
import ValidateCodeForm from './ValidateCodeActionModal/ValidateCodeForm'; | ||
import type {ValidateCodeFormHandle} from './ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm'; | ||
|
||
type ValidateCodeActionWithoutModalProps = { | ||
/** Ref for validate code form */ | ||
forwardedRef: ForwardedRef<ValidateCodeFormHandle>; | ||
}; | ||
|
||
type ValidateCodeActionProps = ValidateCodeActionModalProps & ValidateCodeActionWithoutModalProps; | ||
|
||
function ValidateCodeActionWithoutModal({ | ||
isVisible, | ||
descriptionPrimary, | ||
descriptionSecondary, | ||
validatePendingAction, | ||
validateError, | ||
handleSubmitForm, | ||
clearError, | ||
sendValidateCode, | ||
hasMagicCodeBeenSent, | ||
isLoading, | ||
forwardedRef, | ||
}: ValidateCodeActionProps) { | ||
const themeStyles = useThemeStyles(); | ||
const firstRenderRef = useRef(true); | ||
|
||
const [validateCodeAction] = useOnyx(ONYXKEYS.VALIDATE_ACTION_CODE); | ||
|
||
useEffect( | ||
() => () => { | ||
firstRenderRef.current = true; | ||
}, | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
if (!firstRenderRef.current || !isVisible || hasMagicCodeBeenSent) { | ||
return () => { | ||
clearError(); | ||
}; | ||
} | ||
firstRenderRef.current = false; | ||
sendValidateCode(); | ||
}, [isVisible, sendValidateCode, hasMagicCodeBeenSent, clearError]); | ||
Comment on lines
+37
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's not a modal. Do we need |
||
|
||
if (isVisible) { | ||
return ( | ||
<View style={[themeStyles.ph5, themeStyles.mt3, themeStyles.mb5, themeStyles.flex1]}> | ||
<Text style={[themeStyles.mb3]}>{descriptionPrimary}</Text> | ||
{!!descriptionSecondary && <Text style={[themeStyles.mb3]}>{descriptionSecondary}</Text>} | ||
<ValidateCodeForm | ||
isLoading={isLoading} | ||
validateCodeAction={validateCodeAction} | ||
validatePendingAction={validatePendingAction} | ||
validateError={validateError} | ||
handleSubmitForm={handleSubmitForm} | ||
sendValidateCode={sendValidateCode} | ||
clearError={clearError} | ||
buttonStyles={[themeStyles.justifyContentEnd, themeStyles.flex1]} | ||
ref={forwardedRef} | ||
hasMagicCodeBeenSent={hasMagicCodeBeenSent} | ||
/> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
ValidateCodeActionWithoutModal.displayName = 'ValidateCodeActionWithoutModal'; | ||
|
||
export default forwardRef<ValidateCodeFormHandle, ValidateCodeActionProps>((props, ref) => ( | ||
<ValidateCodeActionWithoutModal | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
forwardedRef={ref} | ||
/> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,13 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; | |
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import ScrollView from '@components/ScrollView'; | ||
import Text from '@components/Text'; | ||
import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; | ||
import ValidateCodeActionWithoutModal from '@components/ValidateCodeActionWithoutModal'; | ||
import useBeforeRemove from '@hooks/useBeforeRemove'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import usePrevious from '@hooks/usePrevious'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import blurActiveElement from '@libs/Accessibility/blurActiveElement'; | ||
import { | ||
clearContactMethod, | ||
|
@@ -61,6 +62,7 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
const {formatPhoneNumber, translate} = useLocalize(); | ||
const theme = useTheme(); | ||
const themeStyles = useThemeStyles(); | ||
const {windowWidth} = useWindowDimensions(); | ||
|
||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); | ||
const validateCodeFormRef = useRef<ValidateCodeFormHandle>(null); | ||
|
@@ -270,12 +272,41 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
<ScreenWrapper | ||
onEntryTransitionEnd={() => validateCodeFormRef.current?.focus?.()} | ||
testID={ContactMethodDetailsPage.displayName} | ||
focusTrapSettings={{ | ||
focusTrapOptions: { | ||
// It is added because input form's focusing bothers transition animation: | ||
// https://github.com/Expensify/App/issues/53884#issuecomment-2594568960 | ||
checkCanFocusTrap: (trapContainers: Array<HTMLElement | SVGElement>) => { | ||
return new Promise((resolve) => { | ||
const interval = setInterval(() => { | ||
const trapContainer = trapContainers.at(0); | ||
if (!trapContainer || (trapContainer && getComputedStyle(trapContainer).visibility !== 'hidden')) { | ||
resolve(); | ||
clearInterval(interval); | ||
} | ||
}, 5); | ||
}); | ||
}, | ||
}, | ||
}} | ||
> | ||
<HeaderWithBackButton | ||
title={formattedContactMethod} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo))} | ||
threeDotsMenuItems={getThreeDotsMenuItems()} | ||
shouldShowThreeDotsButton={getThreeDotsMenuItems().length > 0} | ||
shouldOverlayDots | ||
threeDotsAnchorPosition={themeStyles.threeDotsPopoverOffset(windowWidth)} | ||
onThreeDotsButtonPress={() => { | ||
// Hide the keyboard when the user clicks the three-dot menu. | ||
// Use blurActiveElement() for mWeb and KeyboardUtils.dismiss() for native apps. | ||
blurActiveElement(); | ||
KeyboardUtils.dismiss(); | ||
}} | ||
/> | ||
<ScrollView keyboardShouldPersistTaps="handled"> | ||
<ScrollView | ||
keyboardShouldPersistTaps="handled" | ||
contentContainerStyle={themeStyles.flex1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you elaborate why do we need this style? |
||
> | ||
{isFailedAddContactMethod && ( | ||
<ErrorMessageRow | ||
errors={getLatestErrorField(loginData, 'addedLogin')} | ||
|
@@ -289,29 +320,16 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { | |
/> | ||
)} | ||
|
||
<ValidateCodeActionModal | ||
title={formattedContactMethod} | ||
onModalHide={() => {}} | ||
<ValidateCodeActionWithoutModal | ||
hasMagicCodeBeenSent={hasMagicCodeBeenSent} | ||
isVisible={isValidateCodeActionModalVisible && !loginData.validatedDate && !!loginData} | ||
validatePendingAction={loginData.pendingFields?.validateCodeSent} | ||
handleSubmitForm={(validateCode) => validateSecondaryLogin(loginList, contactMethod, validateCode)} | ||
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')} | ||
clearError={() => clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')} | ||
onClose={() => { | ||
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(backTo)); | ||
setIsValidateCodeActionModalVisible(false); | ||
}} | ||
sendValidateCode={() => requestContactMethodValidateCode(contactMethod)} | ||
descriptionPrimary={translate('contacts.enterMagicCode', {contactMethod: formattedContactMethod})} | ||
onThreeDotsButtonPress={() => { | ||
// Hide the keyboard when the user clicks the three-dot menu. | ||
// Use blurActiveElement() for mWeb and KeyboardUtils.dismiss() for native apps. | ||
blurActiveElement(); | ||
KeyboardUtils.dismiss(); | ||
}} | ||
threeDotsMenuItems={getThreeDotsMenuItems()} | ||
footer={getDeleteConfirmationModal} | ||
forwardedRef={validateCodeFormRef} | ||
/> | ||
|
||
{!isValidateCodeActionModalVisible && getMenuItems()} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any other names for this component? It seems is not a good name.