Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 7 additions & 31 deletions src/components/Navigation/NavigationTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ import {startSpan} from '@libs/telemetry/activeSpans';
import type {BrickRoad} from '@libs/WorkspacesSettingsUtils';
import {getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils';
import navigationRef from '@navigation/navigationRef';
import type {
DomainSplitNavigatorParamList,
ReportsSplitNavigatorParamList,
RootNavigatorParamList,
SearchFullscreenNavigatorParamList,
State,
WorkspaceSplitNavigatorParamList,
} from '@navigation/types';
import type {DomainSplitNavigatorParamList, RootNavigatorParamList, SearchFullscreenNavigatorParamList, State, WorkspaceSplitNavigatorParamList} from '@navigation/types';
import NavigationTabBarAvatar from '@pages/home/sidebar/NavigationTabBarAvatar';
import NavigationTabBarFloatingActionButton from '@pages/home/sidebar/NavigationTabBarFloatingActionButton';
import variables from '@styles/variables';
Expand All @@ -61,14 +54,6 @@ type NavigationTabBarProps = {
shouldShowFloatingCameraButton?: boolean;
};

function getLastRoute(navigator: string, screen: string) {
const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>;
const lastNavigator = rootState.routes.findLast((route) => route.name === navigator);
const lastNavigatorState = lastNavigator && lastNavigator.key ? getPreservedNavigatorState(lastNavigator?.key) : undefined;
const lastRoute = lastNavigatorState?.routes.findLast((route) => route.name === screen);
return lastRoute;
}

function NavigationTabBar({selectedTab, isTopLevelBar = false, shouldShowFloatingCameraButton = true}: NavigationTabBarProps) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -176,21 +161,8 @@ function NavigationTabBar({selectedTab, isTopLevelBar = false, shouldShowFloatin
name: CONST.TELEMETRY.SPAN_NAVIGATE_TO_INBOX_TAB,
op: CONST.TELEMETRY.SPAN_NAVIGATE_TO_INBOX_TAB,
});

if (shouldUseNarrowLayout) {
Navigation.navigate(ROUTES.HOME);
return;
}

const lastReportRoute = getLastRoute(NAVIGATORS.REPORTS_SPLIT_NAVIGATOR, SCREENS.REPORT);
if (lastReportRoute) {
const {reportID, reportActionID, referrer, backTo} = lastReportRoute.params as ReportsSplitNavigatorParamList[typeof SCREENS.REPORT];
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID, referrer, backTo));
return;
}

Navigation.navigate(ROUTES.HOME);
Comment on lines 161 to 164

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve last inbox report when switching to Inbox

Always navigating to ROUTES.HOME here drops the preserved ReportsSplitNavigator state and rebuilds the split with only the HOME route; on wide layout, SplitRouter fills the central pane with the default SCREENS.REPORT, which uses ReportUtils.findLastAccessedReport for initialReportID (ReportsSplitNavigator.tsx lines 36–51). If the user just opened a report from the Search tab, that report becomes the last accessed, so switching to Inbox shows the same report again instead of the last Inbox report/list—reintroducing the “Inbox shows the report opened from Reports” regression.

Useful? React with 👍 / 👎.

}, [selectedTab, shouldUseNarrowLayout]);
}, [selectedTab]);

const [lastSearchParams] = useOnyx(ONYXKEYS.REPORT_NAVIGATION_LAST_SEARCH_QUERY, {canBeMissing: true});

Expand All @@ -210,7 +182,11 @@ function NavigationTabBar({selectedTab, isTopLevelBar = false, shouldShowFloatin
op: CONST.TELEMETRY.SPAN_ON_LAYOUT_SKELETON_REPORTS,
});

const lastSearchRoute = getLastRoute(NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR, SCREENS.SEARCH.ROOT);
const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>;
const lastSearchNavigator = rootState.routes.findLast((route) => route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR);
const lastSearchNavigatorState = lastSearchNavigator && lastSearchNavigator.key ? getPreservedNavigatorState(lastSearchNavigator?.key) : undefined;
const lastSearchRoute = lastSearchNavigatorState?.routes.findLast((route) => route.name === SCREENS.SEARCH.ROOT);

if (lastSearchRoute) {
const {q, ...rest} = lastSearchRoute.params as SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.ROOT];
const queryJSON = buildSearchQueryJSON(q);
Expand Down
Loading