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: Scan - Clicking outside of the allow location modal submits the scan expense. #48620

Merged
merged 3 commits into from
Sep 6, 2024
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
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 @@ -139,6 +143,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
Loading