From 5f16ef925b2f922f3252885ef9b6655ac9443647 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 25 Jul 2022 15:22:08 -1000 Subject: [PATCH 1/2] Revert changes made in #9706 --- src/libs/Navigation/CustomActions.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/libs/Navigation/CustomActions.js b/src/libs/Navigation/CustomActions.js index 348bbef076b3..c5fb5f2a4154 100644 --- a/src/libs/Navigation/CustomActions.js +++ b/src/libs/Navigation/CustomActions.js @@ -3,10 +3,8 @@ import { CommonActions, StackActions, DrawerActions, getStateFromPath, } from '@react-navigation/native'; import lodashGet from 'lodash/get'; -import {Dimensions} from 'react-native'; import linkingConfig from './linkingConfig'; import navigationRef from './navigationRef'; -import variables from '../../styles/variables'; /** * @returns {Object} @@ -71,9 +69,6 @@ function getScreenNameFromState(state) { */ function pushDrawerRoute(route) { return (currentState) => { - const initialDimensions = Dimensions.get('window'); - const isSmallScreenWidth = initialDimensions.width <= variables.mobileResponsiveWidthBreakpoint; - // Parse the state, name, and params from the new route we want to navigate to. const newStateFromRoute = getStateFromPath(route, linkingConfig.config); const newScreenName = getScreenNameFromState(newStateFromRoute); @@ -108,18 +103,13 @@ function pushDrawerRoute(route) { // Force drawer to close // https://github.com/react-navigation/react-navigation/blob/94ab791cae5061455f036cd3f6bc7fa63167e7c7/packages/routers/src/DrawerRouter.tsx#L142 const hasDrawerhistory = _.find(state.history || [], h => h.type === 'drawer'); - if (isSmallScreenWidth && (!hasDrawerhistory || currentState.type !== 'drawer')) { + if (!hasDrawerhistory || currentState.type !== 'drawer') { history.push({ type: 'drawer', // If current state is not from drawer navigator then always use closed status to close the drawer status: currentState.type !== 'drawer' || currentState.default === 'open' ? 'closed' : 'open', }); - } else { - history.push({ - type: 'route', - name: newScreenName, - }); } return CommonActions.reset({ From 946375c236f0689c1bc227b6c1af6a055d2a631e Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 25 Jul 2022 15:24:54 -1000 Subject: [PATCH 2/2] Rename to DeprecatedCustomActions --- .../{CustomActions.js => DeprecatedCustomActions.js} | 2 ++ src/libs/Navigation/Navigation.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) rename src/libs/Navigation/{CustomActions.js => DeprecatedCustomActions.js} (99%) diff --git a/src/libs/Navigation/CustomActions.js b/src/libs/Navigation/DeprecatedCustomActions.js similarity index 99% rename from src/libs/Navigation/CustomActions.js rename to src/libs/Navigation/DeprecatedCustomActions.js index c5fb5f2a4154..1c192d60f93e 100644 --- a/src/libs/Navigation/CustomActions.js +++ b/src/libs/Navigation/DeprecatedCustomActions.js @@ -16,6 +16,7 @@ function getActiveState() { /** * Go back to the Main Drawer + * @deprecated * @param {Object} navigationRef */ function navigateBackToRootDrawer() { @@ -64,6 +65,7 @@ function getScreenNameFromState(state) { * * More context here: https://github.com/react-navigation/react-navigation/issues/9744 * + * @deprecated * @param {String} route * @returns {Function} */ diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index c19f10c635d8..6891244a2760 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -5,7 +5,7 @@ import Onyx from 'react-native-onyx'; import Log from '../Log'; import linkTo from './linkTo'; import ROUTES from '../../ROUTES'; -import CustomActions from './CustomActions'; +import DeprecatedCustomActions from './DeprecatedCustomActions'; import ONYXKEYS from '../../ONYXKEYS'; import linkingConfig from './linkingConfig'; import navigationRef from './navigationRef'; @@ -140,7 +140,7 @@ function navigate(route = ROUTES.HOME) { } if (isDrawerRoute(route)) { - navigationRef.current.dispatch(CustomActions.pushDrawerRoute(route)); + navigationRef.current.dispatch(DeprecatedCustomActions.pushDrawerRoute(route)); return; } @@ -161,7 +161,7 @@ function dismissModal(shouldOpenDrawer = false) { ? shouldOpenDrawer : false; - CustomActions.navigateBackToRootDrawer(); + DeprecatedCustomActions.navigateBackToRootDrawer(); if (normalizedShouldOpenDrawer) { openDrawer(); }