From 174679df616f0723c654f89093b4fd7af64d7f14 Mon Sep 17 00:00:00 2001 From: Cong Pham Date: Wed, 25 Oct 2023 00:24:21 +0700 Subject: [PATCH 1/8] fix go back from flag comment page to report --- src/pages/FlagCommentPage.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 53da810007ea..beb5438bceb5 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -22,6 +22,7 @@ import * as Session from '../libs/actions/Session'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound'; import ONYXKEYS from '../ONYXKEYS'; +import ROUTES from '../ROUTES'; const propTypes = { /** Array of report actions for this report */ @@ -160,7 +161,10 @@ function FlagCommentPage(props) { > {({safeAreaPaddingBottomStyle}) => ( - + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID))} + /> Date: Thu, 26 Oct 2023 07:30:43 +0700 Subject: [PATCH 2/8] only update for browser mobile --- src/pages/FlagCommentPage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index beb5438bceb5..06eabee02ea9 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -11,6 +11,7 @@ import ScreenWrapper from '../components/ScreenWrapper'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; import styles from '../styles/styles'; import Navigation from '../libs/Navigation/Navigation'; +import * as Browser from '../libs/Browser'; import Text from '../components/Text'; import * as Expensicons from '../components/Icon/Expensicons'; import MenuItem from '../components/MenuItem'; @@ -163,7 +164,7 @@ function FlagCommentPage(props) { Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID))} + onBackButtonPress={Browser.isMobile() ? () => Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)) : undefined} /> Date: Fri, 27 Oct 2023 00:57:51 +0700 Subject: [PATCH 3/8] update navigation back to navigate --- src/pages/FlagCommentPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 06eabee02ea9..4882bd332c7d 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -164,7 +164,7 @@ function FlagCommentPage(props) { Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)) : undefined} + onBackButtonPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID))} /> Date: Fri, 27 Oct 2023 01:02:55 +0700 Subject: [PATCH 4/8] fix code lint --- src/pages/FlagCommentPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 4882bd332c7d..bef16145d0de 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -11,7 +11,6 @@ import ScreenWrapper from '../components/ScreenWrapper'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; import styles from '../styles/styles'; import Navigation from '../libs/Navigation/Navigation'; -import * as Browser from '../libs/Browser'; import Text from '../components/Text'; import * as Expensicons from '../components/Icon/Expensicons'; import MenuItem from '../components/MenuItem'; From e61f16f0169ed6c4402d2b063d3ffe0c0b68ba6e Mon Sep 17 00:00:00 2001 From: Cong Pham Date: Fri, 27 Oct 2023 01:34:47 +0700 Subject: [PATCH 5/8] handle go back by topMostReportID --- src/pages/FlagCommentPage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index bef16145d0de..85a51ebf883b 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -163,7 +163,15 @@ function FlagCommentPage(props) { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID))} + onBackButtonPress={() => { + const topMostReportID = Navigation.getTopmostReportId(); + if (topMostReportID) { + Navigation.goBack(ROUTES.HOME); + return; + } + Navigation.goBack(); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)); + }} /> Date: Sat, 11 Nov 2023 22:27:43 +0700 Subject: [PATCH 6/8] run prettier --- src/pages/FlagCommentPage.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 2d21c0fef514..739f5fe0b028 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; -import React, { useCallback } from 'react'; -import { ScrollView, View } from 'react-native'; -import { withOnyx } from 'react-native-onyx'; +import React, {useCallback} from 'react'; +import {ScrollView, View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -9,7 +9,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; -import withLocalize, { withLocalizePropTypes } from '@components/withLocalize'; +import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; @@ -24,7 +24,6 @@ import reportActionPropTypes from './home/report/reportActionPropTypes'; import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound'; import reportPropTypes from './reportPropTypes'; - const propTypes = { /** Array of report actions for this report */ reportActions: PropTypes.shape(reportActionPropTypes), @@ -205,4 +204,4 @@ export default compose( canEvict: false, }, }), -)(FlagCommentPage); \ No newline at end of file +)(FlagCommentPage); From 0f164c76482a3a8915482d1f3c6fe6e7afbeb23a Mon Sep 17 00:00:00 2001 From: Cong Pham Date: Mon, 20 Nov 2023 08:45:42 +0700 Subject: [PATCH 7/8] move condition check topMostReportID to HeaderWithBackButton --- .../HeaderWithBackButton/headerWithBackButtonPropTypes.js | 3 +++ src/components/HeaderWithBackButton/index.js | 7 ++++++- src/pages/FlagCommentPage.js | 6 +----- src/pages/ReportDetailsPage.js | 6 +----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js index 1ad1f0961e38..85dcbfaa4bf3 100644 --- a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js +++ b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js @@ -93,6 +93,9 @@ const propTypes = { /** Single execution function to prevent concurrent navigation actions */ singleExecution: PropTypes.func, + + /** Whether we should navigate to home when the route have a topMostReport */ + shouldAwareTopMostReport: PropTypes.bool, }; export default propTypes; diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index edb3b8d26831..7494f67d392d 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -53,6 +53,7 @@ function HeaderWithBackButton({ children = null, shouldOverlay = false, singleExecution = (func) => func, + shouldAwareTopMostReport = false, }) { const styles = useThemeStyles(); const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState(); @@ -74,7 +75,11 @@ function HeaderWithBackButton({ if (isKeyboardShown) { Keyboard.dismiss(); } - onBackButtonPress(); + if (shouldAwareTopMostReport && Navigation.getTopmostReportId()) { + Navigation.goBack(ROUTES.HOME); + } else { + onBackButtonPress(); + } }} style={[styles.touchableButtonImage]} role="button" diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 05e92f74f2fa..696b8f183a5a 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -164,12 +164,8 @@ function FlagCommentPage(props) { { - const topMostReportID = Navigation.getTopmostReportId(); - if (topMostReportID) { - Navigation.goBack(ROUTES.HOME); - return; - } Navigation.goBack(); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)); }} diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 88d5ddec0c54..50e97d04957f 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -167,12 +167,8 @@ function ReportDetailsPage(props) { { - const topMostReportID = Navigation.getTopmostReportId(); - if (topMostReportID) { - Navigation.goBack(ROUTES.HOME); - return; - } Navigation.goBack(); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)); }} From e43e3dbb55d364b19240beda424a69c7caaaf11d Mon Sep 17 00:00:00 2001 From: Cong Pham Date: Tue, 28 Nov 2023 14:01:17 +0700 Subject: [PATCH 8/8] rename props --- .../HeaderWithBackButton/headerWithBackButtonPropTypes.js | 4 ++-- src/components/HeaderWithBackButton/index.js | 7 ++++--- src/pages/FlagCommentPage.js | 2 +- src/pages/ReportDetailsPage.js | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js index 85dcbfaa4bf3..109e60adf672 100644 --- a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js +++ b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js @@ -94,8 +94,8 @@ const propTypes = { /** Single execution function to prevent concurrent navigation actions */ singleExecution: PropTypes.func, - /** Whether we should navigate to home when the route have a topMostReport */ - shouldAwareTopMostReport: PropTypes.bool, + /** Whether we should navigate to report page when the route have a topMostReport */ + shouldNavigateToTopMostReport: PropTypes.bool, }; export default propTypes; diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index 7494f67d392d..051e18ed675e 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -53,7 +53,7 @@ function HeaderWithBackButton({ children = null, shouldOverlay = false, singleExecution = (func) => func, - shouldAwareTopMostReport = false, + shouldNavigateToTopMostReport = false, }) { const styles = useThemeStyles(); const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState(); @@ -75,8 +75,9 @@ function HeaderWithBackButton({ if (isKeyboardShown) { Keyboard.dismiss(); } - if (shouldAwareTopMostReport && Navigation.getTopmostReportId()) { - Navigation.goBack(ROUTES.HOME); + const topmostReportId = Navigation.getTopmostReportId(); + if (shouldNavigateToTopMostReport && topmostReportId) { + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(topmostReportId)); } else { onBackButtonPress(); } diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 696b8f183a5a..3695896ea473 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -164,7 +164,7 @@ function FlagCommentPage(props) { { Navigation.goBack(); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID)); diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 50e97d04957f..41e3cd4025ef 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -167,7 +167,7 @@ function ReportDetailsPage(props) { { Navigation.goBack(); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID));