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: Workspace - Inconsistent back navigation when clicking app back button #56204

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ const ROUTES = {
},
WORKSPACE_PROFILE: {
route: 'settings/workspaces/:policyID/profile',
getRoute: (policyID: string | undefined) => {
getRoute: (policyID: string | undefined, backTo?: string) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the WORKSPACE_PROFILE route');
}
return `settings/workspaces/${policyID}/profile` as const;
return getUrlWithBackToParam(`settings/workspaces/${policyID}/profile` as const, backTo);
},
},
WORKSPACE_PROFILE_ADDRESS: {
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ type FullScreenNavigatorParamList = {
};
[SCREENS.WORKSPACE.PROFILE]: {
policyID: string;
backTo?: Routes;
};
[SCREENS.WORKSPACE.EXPENSIFY_CARD]: {
policyID: string;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,12 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
if (!report?.policyID) {
return;
}
const activeRoute = Navigation.getActiveRoute();
if (isSmallScreenWidth) {
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID));
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(report?.policyID, activeRoute));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_PROFILE.getRoute(report?.policyID));
Navigation.navigate(ROUTES.WORKSPACE_PROFILE.getRoute(report?.policyID, activeRoute));
},
isAnonymousAction: false,
shouldShowRightIcon: true,
Expand Down
8 changes: 8 additions & 0 deletions src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac
const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace();
const {canUseSpotnanaTravel} = usePermissions();

const backTo = route.params.backTo;
const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST);
const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID});

Expand Down Expand Up @@ -188,6 +189,13 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, route}: Workspac
shouldShowNonAdmin
icon={Illustrations.Building}
shouldShowNotFoundPage={policy === undefined}
onBackButtonPress={() => {
if (backTo) {
Navigation.navigate(backTo);
return;
}
return Navigation.goBack();
}}
>
{(hasVBA?: boolean) => (
<View style={[styles.flex1, styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
Expand Down