From d7542be695589e3aa18da9cd6941117da64f73ec Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 26 Jun 2024 14:25:40 -0600 Subject: [PATCH] Merge pull request #44444 from software-mansion-labs/fix/link-to-without-central-pane Fix navigating between CentralPane screens (cherry picked from commit f757005dad95d4d1e86290891fea0708c659400c) --- src/libs/Navigation/linkTo/index.ts | 16 ++++++++++------ src/libs/NavigationUtils.ts | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libs/Navigation/linkTo/index.ts b/src/libs/Navigation/linkTo/index.ts index 90e52d02163c..3c4608d6b5de 100644 --- a/src/libs/Navigation/linkTo/index.ts +++ b/src/libs/Navigation/linkTo/index.ts @@ -72,17 +72,21 @@ export default function linkTo(navigation: NavigationContainerRef | undefined, (value) => value === undefined), - omitBy(actionParams?.params as Record | undefined, (value) => value === undefined), + omitBy(targetParams as Record | undefined, (value) => value === undefined), ); // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack by default @@ -110,8 +114,8 @@ export default function linkTo(navigation: NavigationContainerRef).policyIDs = policyID; + if (targetName === SCREENS.SEARCH.CENTRAL_PANE && targetParams && policyID) { + (targetParams as Record).policyIDs = policyID; } // If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow diff --git a/src/libs/NavigationUtils.ts b/src/libs/NavigationUtils.ts index f0442e4995d2..4fdc03c3d334 100644 --- a/src/libs/NavigationUtils.ts +++ b/src/libs/NavigationUtils.ts @@ -1,7 +1,7 @@ import SCREENS from '@src/SCREENS'; import type {CentralPaneName} from './Navigation/types'; -const CENTRAL_PANE_SCREEN_NAMES = [ +const CENTRAL_PANE_SCREEN_NAMES = new Set([ SCREENS.SETTINGS.WORKSPACES, SCREENS.SETTINGS.PREFERENCES.ROOT, SCREENS.SETTINGS.SECURITY, @@ -13,14 +13,14 @@ const CENTRAL_PANE_SCREEN_NAMES = [ SCREENS.SETTINGS.SUBSCRIPTION.ROOT, SCREENS.SEARCH.CENTRAL_PANE, SCREENS.REPORT, -]; +]); function isCentralPaneName(screen: string | undefined): screen is CentralPaneName { if (!screen) { return false; } - return CENTRAL_PANE_SCREEN_NAMES.includes(screen as CentralPaneName); + return CENTRAL_PANE_SCREEN_NAMES.has(screen as CentralPaneName); } export default isCentralPaneName;