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 go back from flag comment page to report #30289

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const propTypes = {

/** Single execution function to prevent concurrent navigation actions */
singleExecution: PropTypes.func,

/** Whether we should navigate to report page when the route have a topMostReport */
shouldNavigateToTopMostReport: PropTypes.bool,
};

export default propTypes;
8 changes: 7 additions & 1 deletion src/components/HeaderWithBackButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function HeaderWithBackButton({
children = null,
shouldOverlay = false,
singleExecution = (func) => func,
shouldNavigateToTopMostReport = false,
}) {
const styles = useThemeStyles();
const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState();
Expand All @@ -74,7 +75,12 @@ function HeaderWithBackButton({
if (isKeyboardShown) {
Keyboard.dismiss();
}
onBackButtonPress();
const topmostReportId = Navigation.getTopmostReportId();
if (shouldNavigateToTopMostReport && topmostReportId) {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(topmostReportId));
} else {
onBackButtonPress();
}
}}
style={[styles.touchableButtonImage]}
role="button"
Expand Down
10 changes: 9 additions & 1 deletion src/pages/FlagCommentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as Report from '@userActions/Report';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import reportActionPropTypes from './home/report/reportActionPropTypes';
import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound';
import reportPropTypes from './reportPropTypes';
Expand Down Expand Up @@ -161,7 +162,14 @@ function FlagCommentPage(props) {
>
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={!ReportUtils.shouldShowFlagComment(getActionToFlag(), props.report)}>
<HeaderWithBackButton title={props.translate('reportActionContextMenu.flagAsOffensive')} />
<HeaderWithBackButton
title={props.translate('reportActionContextMenu.flagAsOffensive')}
shouldNavigateToTopMostReport
onBackButtonPress={() => {
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID));
}}
/>
<ScrollView
contentContainerStyle={safeAreaPaddingBottomStyle}
style={styles.settingsPageBackground}
Expand Down
6 changes: 1 addition & 5 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,8 @@ function ReportDetailsPage(props) {
<FullPageNotFoundView shouldShow={_.isEmpty(props.report)}>
<HeaderWithBackButton
title={props.translate('common.details')}
shouldNavigateToTopMostReport
onBackButtonPress={() => {
const topMostReportID = Navigation.getTopmostReportId();
if (topMostReportID) {
Navigation.goBack(ROUTES.HOME);
return;
}
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.report.reportID));
}}
Expand Down
Loading