Skip to content

Commit

Permalink
fix navigation back from private notes pages
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Feb 3, 2025
1 parent f60c647 commit fd2925a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4456,7 +4456,7 @@ function navigateToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
/**
* Go back to the details page of a given report
*/
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string, shouldGoBackToDetailsPage = false) {
const isOneOnOneChatReport = isOneOnOneChat(report);
const participantAccountID = getParticipantsAccountIDsForDisplay(report);

Expand All @@ -4466,7 +4466,11 @@ function goBackToDetailsPage(report: OnyxEntry<Report>, backTo?: string) {
}

if (report?.reportID) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
if (shouldGoBackToDetailsPage) {
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo));
} else {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, backTo));
}
} else {
Log.warn('Missing reportID during navigation back to the details page');
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PrivateNotes/PrivateNotesEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function PrivateNotesEditPage({route, report, accountID}: PrivateNotesEditPagePr

Keyboard.dismiss();
if (!Object.values<Note>({...report.privateNotes, [route.params.accountID]: {note: editedNote}}).some((item) => item.note)) {
ReportUtils.navigateToDetailsPage(report, backTo);
ReportUtils.goBackToDetailsPage(report, backTo, true);
} else {
Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(ROUTES.PRIVATE_NOTES_LIST.getRoute(report.reportID, backTo)));
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/PrivateNotes/PrivateNotesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {PrivateNotesNavigatorParamList} from '@libs/Navigation/types';
import {goBackToDetailsPage} from '@libs/ReportUtils';
import type {WithReportAndPrivateNotesOrNotFoundProps} from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import withReportAndPrivateNotesOrNotFound from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -94,7 +95,7 @@ function PrivateNotesListPage({report, accountID: sessionAccountID}: PrivateNote
<HeaderWithBackButton
title={translate('privateNotes.title')}
shouldShowBackButton
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID, backTo))}
onBackButtonPress={() => goBackToDetailsPage(report, route.params.backTo, true)}
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<ScrollView
Expand Down

0 comments on commit fd2925a

Please sign in to comment.