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 home when the route have a topMostReport */
shouldAwareTopMostReport: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is not great, why not navigateToTopMostReport?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, isn't this really navigating to home and not to the topmost report?

Copy link
Contributor Author

@suneox suneox Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated prop name

Also, isn't this really navigating to home and not to the topmost report?

Because the home page has loaded topmost report so when we navigate to home the report is also already but to avoid confusion for this case I have updated the function to navigate the report page with topMostReportId.

};

export default propTypes;
7 changes: 6 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,
shouldAwareTopMostReport = false,
}) {
const styles = useThemeStyles();
const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState();
Expand All @@ -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"
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')}
shouldAwareTopMostReport
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')}
shouldAwareTopMostReport
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