diff --git a/native/navigation/nav-selectors.js b/native/navigation/nav-selectors.js --- a/native/navigation/nav-selectors.js +++ b/native/navigation/nav-selectors.js @@ -317,7 +317,7 @@ }, ); -const getChatNavState: ( +const getTabNavState: ( navigationState: ?PossiblyStaleNavigationState, ) => ?PossiblyStaleNavigationState = ( navigationState: ?PossiblyStaleNavigationState, @@ -337,6 +337,14 @@ } const tabState = getStateFromNavigatorRoute(firstCommunityDrawerSubroute); + return tabState; +}; + +const getChatNavStateFromTabNavState: ( + tabState: ?PossiblyStaleNavigationState, +) => ?PossiblyStaleNavigationState = ( + tabState: ?PossiblyStaleNavigationState, +) => { if (!tabState) { return null; } @@ -402,5 +410,6 @@ drawerSwipeEnabledSelector, useCurrentLeafRouteName, getRemoveEditMode, - getChatNavState, + getTabNavState, + getChatNavStateFromTabNavState, }; diff --git a/native/navigation/overlay-router.js b/native/navigation/overlay-router.js --- a/native/navigation/overlay-router.js +++ b/native/navigation/overlay-router.js @@ -15,7 +15,11 @@ clearOverlayModalsActionType, setRouteParamsActionType, } from './action-types.js'; -import { getRemoveEditMode, getChatNavState } from './nav-selectors.js'; +import { + getChatNavStateFromTabNavState, + getRemoveEditMode, + getTabNavState, +} from './nav-selectors.js'; import { removeScreensFromStack } from './navigation-utils.js'; type ClearOverlayModalsAction = { @@ -57,7 +61,8 @@ action: OverlayRouterNavigationAction, options: RouterConfigOptions, ) => { - const chatNavState = getChatNavState(lastState); + const tabNavState = getTabNavState(lastState); + const chatNavState = getChatNavStateFromTabNavState(tabNavState); const removeEditMode = getRemoveEditMode(chatNavState); if (action.type === clearOverlayModalsActionType) { const { keys } = action.payload; diff --git a/native/navigation/tab-router.js b/native/navigation/tab-router.js --- a/native/navigation/tab-router.js +++ b/native/navigation/tab-router.js @@ -8,6 +8,11 @@ } from '@react-navigation/native'; import { TabRouter } from '@react-navigation/native'; +import { + getChatNavStateFromTabNavState, + getRemoveEditMode, +} from './nav-selectors.js'; + type TabRouterNavigationAction = empty; export type TabRouterExtraNavigationHelpers = {}; @@ -24,6 +29,12 @@ action: TabRouterNavigationAction, options: RouterConfigOptions, ) => { + const chatNavState = getChatNavStateFromTabNavState(lastState); + const removeEditMode = getRemoveEditMode(chatNavState); + if (removeEditMode) { + removeEditMode(action); + return lastState; + } return baseGetStateForAction(lastState, action, options); }, };