From 71a24255d6075d3d45b13980a994caab51f6a504 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 1 Mar 2024 17:43:22 +0100 Subject: [PATCH] Fix opening RHP in FullScreenNavigator --- .../Navigation/linkingConfig/getAdaptedStateFromPath.ts | 5 +++++ .../linkingConfig/getMatchingBottomTabRouteForState.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 3ff52bcee2c7..e4a8464d7ddd 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -182,6 +182,11 @@ function getAdaptedState(state: PartialState // If the root route is type of FullScreenNavigator, the default bottom tab will be added. const matchingBottomTabRoute = getMatchingBottomTabRouteForState({routes: [matchingRootRoute]}); routes.push(createBottomTabNavigator(matchingBottomTabRoute, policyID)); + // When we open a screen in RHP from FullScreenNavigator, we need to add the appropriate screen in CentralPane. + // Then, when we close FullScreenNavigator, we will be redirected to the correct page in CentralPane. + if (matchingRootRoute.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { + routes.push(createCentralPaneNavigator({name: SCREENS.SETTINGS.WORKSPACES})); + } if (!isNarrowLayout || !isRHPScreenOpenedFromLHN) { routes.push(matchingRootRoute); } diff --git a/src/libs/Navigation/linkingConfig/getMatchingBottomTabRouteForState.ts b/src/libs/Navigation/linkingConfig/getMatchingBottomTabRouteForState.ts index e85e7ca950dd..65d7f402ee56 100644 --- a/src/libs/Navigation/linkingConfig/getMatchingBottomTabRouteForState.ts +++ b/src/libs/Navigation/linkingConfig/getMatchingBottomTabRouteForState.ts @@ -1,5 +1,6 @@ import getTopmostCentralPaneRoute from '@libs/Navigation/getTopmostCentralPaneRoute'; import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from '@libs/Navigation/types'; +import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; import {CENTRAL_PANE_TO_TAB_MAPPING} from './TAB_TO_CENTRAL_PANE_MAPPING'; @@ -7,6 +8,12 @@ import {CENTRAL_PANE_TO_TAB_MAPPING} from './TAB_TO_CENTRAL_PANE_MAPPING'; function getMatchingBottomTabRouteForState(state: State, policyID?: string): NavigationPartialRoute { const paramsWithPolicyID = policyID ? {policyID} : undefined; const defaultRoute = {name: SCREENS.HOME, params: paramsWithPolicyID}; + const isFullScreenNavigatorOpened = state.routes.some((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR); + + if (isFullScreenNavigatorOpened) { + return {name: SCREENS.SETTINGS.ROOT, params: paramsWithPolicyID}; + } + const topmostCentralPaneRoute = getTopmostCentralPaneRoute(state); if (topmostCentralPaneRoute === undefined) {