Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/components/Navigation/NavigationTabBar/getLastRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ function getLastRoute(rootState: NavigationState, navigator: ValueOf<typeof NAVI
let lastNavigatorKey = rootState.routes.findLast((route) => route.name === navigator)?.key;

if (!lastNavigatorKey) {
const rootTabRoute = rootState.routes.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR);
let rootTabRoute = rootState.routes.findLast((route) => {
if (route.name !== NAVIGATORS.TAB_NAVIGATOR) {
return false;
}
const tabState = getTabState(route);
return tabState?.routes?.[tabState.index ?? 0]?.name === navigator;
Comment on lines +13 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't restore reports from an older tab stack

When an older TAB_NAVIGATOR with Inbox/Reports active exists below the current tab stack, this findLast selects that older stack before considering the topmost stack's inactive Reports state. For example on wide layout, if a user opens report A, goes to Spend, opens report B from Spend (pushing a newer Reports tab stack), then switches to Home and presses Inbox, this predicate matches the older report-A stack and navigateToChats restores A instead of the report B state the user just left in the topmost tab navigator. The active-tab preference needs to avoid overriding a newer tab navigator that already has the target navigator state.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nkdengineer thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's not a valid case. If the Reports tab here means the report split navigator, it will be the focused route in tabState then we can find them as the last. If Reports tab means the full-screen search navigator, navigateToChats restores the report A is correct.

});
if (!rootTabRoute) {
rootTabRoute = rootState.routes.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR);
}
const tabState = getTabState(rootTabRoute);
lastNavigatorKey = tabState?.routes?.findLast((route) => route.name === navigator)?.key;
}
Expand Down
Loading