Skip to content

Commit 4bcfb58

Browse files
committed
fix: android back button
1 parent 8a770da commit 4bcfb58

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/pages/workspace/WorkspacesListPage.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import type {SettingsSplitNavigatorParamList} from '@libs/Navigation/types';
4141
import {getPolicy, getPolicyBrickRoadIndicatorStatus, getWorkspaceAccountID, isPolicyAdmin, shouldShowPolicy} from '@libs/PolicyUtils';
4242
import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils';
4343
import type {AvatarSource} from '@libs/UserUtils';
44+
import useHandleBackButton from '@pages/Search/useHandleBackButton';
4445
import CONST from '@src/CONST';
4546
import ONYXKEYS from '@src/ONYXKEYS';
4647
import ROUTES from '@src/ROUTES';
@@ -434,6 +435,13 @@ function WorkspacesListPage() {
434435
/>
435436
);
436437

438+
const onBackButtonPress = () => {
439+
Navigation.goBack(route.params?.backTo ?? ROUTES.SETTINGS);
440+
return true;
441+
};
442+
443+
useHandleBackButton(onBackButtonPress);
444+
437445
if (isEmptyObject(workspaces)) {
438446
return (
439447
<ScreenWrapper
@@ -447,7 +455,7 @@ function WorkspacesListPage() {
447455
title={translate('common.workspaces')}
448456
shouldShowBackButton={shouldUseNarrowLayout}
449457
shouldDisplaySearchRouter
450-
onBackButtonPress={() => Navigation.goBack(route.params?.backTo ?? ROUTES.SETTINGS)}
458+
onBackButtonPress={onBackButtonPress}
451459
icon={Illustrations.Buildings}
452460
shouldUseHeadlineHeader
453461
/>
@@ -487,7 +495,7 @@ function WorkspacesListPage() {
487495
title={translate('common.workspaces')}
488496
shouldShowBackButton={shouldUseNarrowLayout}
489497
shouldDisplaySearchRouter
490-
onBackButtonPress={() => Navigation.goBack(route.params?.backTo ?? ROUTES.SETTINGS)}
498+
onBackButtonPress={onBackButtonPress}
491499
icon={Illustrations.Buildings}
492500
shouldUseHeadlineHeader
493501
>

0 commit comments

Comments
 (0)