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 @@ }, ); -function getChatNavState( +function getTabNavState( navigationState: ?PossiblyStaleNavigationState, ): ?PossiblyStaleNavigationState { if (!navigationState) { @@ -335,6 +335,12 @@ } const tabState = getStateFromNavigatorRoute(firstCommunityDrawerSubroute); + return tabState; +} + +function getChatNavStateFromTabNavState( + tabState: ?PossiblyStaleNavigationState, +): ?PossiblyStaleNavigationState { if (!tabState) { return null; } @@ -400,5 +406,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,11 @@ action: TabRouterNavigationAction, options: RouterConfigOptions, ) => { + const chatNavState = getChatNavStateFromTabNavState(lastState); + const removeEditMode = getRemoveEditMode(chatNavState); + if (removeEditMode && removeEditMode(action) === 'ignore_action') { + return lastState; + } return baseGetStateForAction(lastState, action, options); }, };