Skip to content

Commit

Permalink
Merge pull request Expensify#48620 from Krishna2323/krishna2323/issue…
Browse files Browse the repository at this point in the history
…/47857

fix: Scan - Clicking outside of the allow location modal submits the scan expense.
  • Loading branch information
Julesssss authored Sep 6, 2024
2 parents da8370f + a6a92ad commit ec012fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type ConfirmModalProps = {
/** A callback to call when the form has been closed */
onCancel?: () => void;

/** A callback to call when backdrop is pressed */
onBackdropPress?: () => void;

/** Modal visibility */
isVisible: boolean;

Expand Down Expand Up @@ -108,6 +111,7 @@ function ConfirmModal({
success = true,
danger = false,
onCancel = () => {},
onBackdropPress = () => {},
shouldDisableConfirmButtonWhenOffline = false,
shouldShowCancelButton = true,
shouldSetModalVisibility = true,
Expand Down Expand Up @@ -140,6 +144,7 @@ function ConfirmModal({
<Modal
onSubmit={onConfirm}
onClose={onCancel}
onBackdropPress={onBackdropPress}
isVisible={isVisible}
shouldSetModalVisibility={shouldSetModalVisibility}
onModalHide={onModalHide}
Expand Down
6 changes: 6 additions & 0 deletions src/components/LocationPermissionModal/index.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
setHasError(false);
};

const closeModal = () => {
setShowModal(false);
resetPermissionFlow();
};

return (
<ConfirmModal
isVisible={showModal}
onConfirm={grantLocationPermission}
onCancel={skipLocationPermission}
onBackdropPress={closeModal}
confirmText={hasError ? translate('common.settings') : translate('common.continue')}
cancelText={translate('common.notNow')}
prompt={translate(hasError ? 'receipt.locationErrorMessage' : 'receipt.locationAccessMessage')}
Expand Down
5 changes: 5 additions & 0 deletions src/components/LocationPermissionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
return isWeb ? translate('common.buttonConfirm') : translate('common.settings');
};

const closeModal = () => {
setShowModal(false);
resetPermissionFlow();
};
return (
<ConfirmModal
isVisible={showModal}
onConfirm={grantLocationPermission}
onCancel={skipLocationPermission}
onBackdropPress={closeModal}
confirmText={getConfirmText()}
cancelText={translate('common.notNow')}
prompt={translate(hasError ? 'receipt.locationErrorMessage' : 'receipt.locationAccessMessage')}
Expand Down

0 comments on commit ec012fe

Please sign in to comment.