diff --git a/src/libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS.ts b/src/libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS.ts deleted file mode 100644 index 6ae853a39f46..000000000000 --- a/src/libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS.ts +++ /dev/null @@ -1,19 +0,0 @@ -import SCREENS from '@src/SCREENS'; - -/** - * Leaf screen names that represent the root/landing view of each tab. - * A route whose focused leaf is in this set is considered "at the tab's root" - * — used by TabNavigatorBar to decide tab-bar visibility, and by linkTo to - * distinguish plain tab switches from cross-tab deep navigations. - */ -const ROOT_TAB_SCREENS = new Set([ - SCREENS.HOME, - SCREENS.INBOX, - SCREENS.SEARCH.ROOT, - SCREENS.SETTINGS.ROOT, - SCREENS.WORKSPACES_LIST, - SCREENS.WORKSPACE.INITIAL, - SCREENS.DOMAIN.INITIAL, -]); - -export default ROOT_TAB_SCREENS; diff --git a/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx b/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx index 255f4e296f34..1b40903cc676 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx @@ -13,7 +13,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import getFocusedLeafScreenName from '@libs/Navigation/helpers/getFocusedLeafScreenName'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; -import ROOT_TAB_SCREENS from './ROOT_TAB_SCREENS'; const ROUTE_TO_NAVIGATION_TAB: Record> = { [SCREENS.HOME]: NAVIGATION_TABS.HOME, @@ -31,7 +30,21 @@ const TAB_WRAPPER_NAVIGATORS = new Set([ NAVIGATORS.WORKSPACE_NAVIGATOR, ]); -const isAtTabRootLevel = (name: string | undefined): boolean => !name || ROOT_TAB_SCREENS.has(name) || TAB_WRAPPER_NAVIGATORS.has(name); +/** + * Leaf screen names that represent the root/landing view of each tab. + * Used to decide tab-bar visibility. + */ +const SCREENS_WITH_TAB_BAR = new Set([ + SCREENS.HOME, + SCREENS.INBOX, + SCREENS.SEARCH.ROOT, + SCREENS.SETTINGS.ROOT, + SCREENS.WORKSPACES_LIST, + SCREENS.WORKSPACE.INITIAL, + SCREENS.DOMAIN.INITIAL, +]); + +const isAtTabRootLevel = (name: string | undefined): boolean => !name || SCREENS_WITH_TAB_BAR.has(name) || TAB_WRAPPER_NAVIGATORS.has(name); // Deepest `screen` in a `{screen, params}` chain (e.g. WORKSPACE_NAV → WORKSPACE_SPLIT_NAV → WORKSPACE.INITIAL). const getPushTargetLeaf = (params: unknown): string | undefined => { diff --git a/src/libs/Navigation/helpers/linkTo/index.ts b/src/libs/Navigation/helpers/linkTo/index.ts index 14d1409b51ad..b2d9cf5d6ee0 100644 --- a/src/libs/Navigation/helpers/linkTo/index.ts +++ b/src/libs/Navigation/helpers/linkTo/index.ts @@ -1,7 +1,6 @@ import {getActionFromState} from '@react-navigation/core'; import type {NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native'; import {CommonActions, findFocusedRoute} from '@react-navigation/native'; -import ROOT_TAB_SCREENS from '@libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS'; import findMatchingDynamicSuffix from '@libs/Navigation/helpers/dynamicRoutesUtils/findMatchingDynamicSuffix'; import {getMatchingFullScreenRoute, isFullScreenName} from '@libs/Navigation/helpers/getAdaptedStateFromPath'; import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath'; @@ -23,6 +22,12 @@ const defaultLinkToOptions: LinkToOptions = { forceReplace: false, }; +/** + * Leaf screen names that represent the root/landing view of each tab. + * Used to distinguish plain tab switches from cross-tab deep navigations. + */ +const ROOT_TAB_SCREENS = new Set([SCREENS.HOME, SCREENS.INBOX, SCREENS.SEARCH.ROOT, SCREENS.SETTINGS.ROOT, SCREENS.WORKSPACES_LIST]); + function areNamesAndParamsEqual(currentState: NavigationState, stateFromPath: PartialState>) { const currentFocusedRoute = findFocusedRoute(currentState); const targetFocusedRoute = findFocusedRoute(stateFromPath);