From d36b63eda94763d5aac5fb35bf3bcd40813f66bb Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 30 Apr 2024 17:25:51 +0700 Subject: [PATCH 1/2] fix: back arrow twice to return to LHN --- src/libs/Navigation/linkTo.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 863cb102add4..4284086e1061 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -2,7 +2,6 @@ import {getActionFromState} from '@react-navigation/core'; import type {NavigationAction, NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native'; import type {Writable} from 'type-fest'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; -import shallowCompare from '@libs/ObjectUtils'; import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -14,6 +13,7 @@ import getPolicyIDFromState from './getPolicyIDFromState'; import getStateFromPath from './getStateFromPath'; import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute'; +import getTopmostReportId from './getTopmostReportId'; import linkingConfig from './linkingConfig'; import getAdaptedStateFromPath from './linkingConfig/getAdaptedStateFromPath'; import getMatchingBottomTabRouteForState from './linkingConfig/getMatchingBottomTabRouteForState'; @@ -153,14 +153,14 @@ export default function linkTo(navigation: NavigationContainerRef Date: Wed, 1 May 2024 00:40:37 +0700 Subject: [PATCH 2/2] fix logic link to --- src/libs/Navigation/linkTo.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/Navigation/linkTo.ts b/src/libs/Navigation/linkTo.ts index 4284086e1061..4bddbaf044e7 100644 --- a/src/libs/Navigation/linkTo.ts +++ b/src/libs/Navigation/linkTo.ts @@ -1,7 +1,9 @@ import {getActionFromState} from '@react-navigation/core'; import type {NavigationAction, NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native'; +import {omitBy} from 'lodash'; import type {Writable} from 'type-fest'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; +import shallowCompare from '@libs/ObjectUtils'; import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -13,7 +15,6 @@ import getPolicyIDFromState from './getPolicyIDFromState'; import getStateFromPath from './getStateFromPath'; import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute'; -import getTopmostReportId from './getTopmostReportId'; import linkingConfig from './linkingConfig'; import getAdaptedStateFromPath from './linkingConfig/getAdaptedStateFromPath'; import getMatchingBottomTabRouteForState from './linkingConfig/getMatchingBottomTabRouteForState'; @@ -153,14 +154,16 @@ export default function linkTo(navigation: NavigationContainerRef value === undefined), + omitBy(action.payload.params?.params, (value) => value === undefined), + ); // In case if type is 'FORCED_UP' we replace current screen with the provided. This means the current screen no longer exists in the stack if (type === CONST.NAVIGATION.TYPE.FORCED_UP) { action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE; // 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 - } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && (isTargetScreenDifferentThanCurrent || areReportIDParamsDifferent)) { + } else if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && (isTargetScreenDifferentThanCurrent || areParamsDifferent)) { // We need to push a tab if the tab doesn't match the central pane route that we are going to push. const topmostBottomTabRoute = getTopmostBottomTabRoute(rootState); const matchingBottomTabRoute = getMatchingBottomTabRouteForState(stateFromPath, policyID);