Skip to content

Commit

Permalink
Merge pull request #44823 from bernhardoj/fix/44165-missing-header-io…
Browse files Browse the repository at this point in the history
…u-distance

Fix missing header after reloading page on waypoint screen and go back
  • Loading branch information
grgia authored Jul 12, 2024
2 parents b5f8bd3 + d7b441c commit 7e6375c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ function IOURequestStepDistance({
*/
const navigateToWaypointEditPage = useCallback(
(index: number) => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()),
);
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRoute()));
},
[action, transactionID, report?.reportID],
);
Expand Down
22 changes: 12 additions & 10 deletions src/pages/iou/request/step/IOURequestStepWaypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ function IOURequestStepWaypoint({
isFocused &&
(Number.isNaN(parsedWaypointIndex) || parsedWaypointIndex < 0 || parsedWaypointIndex > waypointCount || (filledWaypointCount < 2 && parsedWaypointIndex >= waypointCount));

const goBack = () => {
if (backTo) {
Navigation.goBack(backTo);
return;
}
Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID));
};

const validate = (values: FormOnyxValues<'waypointForm'>): Partial<Record<string, TranslationPaths>> => {
const errors = {};
const waypointValue = values[`waypoint${pageIndex}`] ?? '';
Expand Down Expand Up @@ -127,14 +135,14 @@ function IOURequestStepWaypoint({
}

// Other flows will be handled by selecting a waypoint with selectWaypoint as this is mainly for the offline flow
Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID));
goBack();
};

const deleteStopAndHideModal = () => {
Transaction.removeWaypoint(transaction, pageIndex, action === CONST.IOU.ACTION.CREATE);
setRestoreFocusType(CONST.MODAL.RESTORE_FOCUS_TYPE.DELETE);
setIsDeleteStopModalOpen(false);
Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID));
goBack();
};

const selectWaypoint = (values: Waypoint) => {
Expand All @@ -147,11 +155,7 @@ function IOURequestStepWaypoint({
};

Transaction.saveWaypoint(transactionID, pageIndex, waypoint, action === CONST.IOU.ACTION.CREATE);
if (backTo) {
Navigation.goBack(backTo);
return;
}
Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID));
goBack();
};

return (
Expand All @@ -165,9 +169,7 @@ function IOURequestStepWaypoint({
<HeaderWithBackButton
title={translate(waypointDescriptionKey)}
shouldShowBackButton
onBackButtonPress={() => {
Navigation.goBack(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID));
}}
onBackButtonPress={goBack}
shouldShowThreeDotsButton={shouldShowThreeDotsButton}
shouldSetModalVisibility={false}
threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)}
Expand Down

0 comments on commit 7e6375c

Please sign in to comment.