Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/hooks/useRestoreWorkspacesTabOnNavigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function useRestoreWorkspacesTabOnNavigate() {
}

// Fall back to session storage when no workspace route exists anywhere in the navigation tree.
const sessionRoute = getWorkspacesTabStateFromSessionStorage()
// getStateFromPath returns state rooted at TAB_NAVIGATOR, so we must drill into it first.
const sessionTabNavigatorRoute = getWorkspacesTabStateFromSessionStorage()?.routes?.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR);
const sessionRoute = getTabState(sessionTabNavigatorRoute)
?.routes?.findLast((route) => route.name === NAVIGATORS.WORKSPACE_NAVIGATOR)
?.state?.routes?.findLast((route) => isWorkspaceNavigatorRouteName(route.name));
if (sessionRoute) {
Expand Down
17 changes: 12 additions & 5 deletions tests/unit/hooks/useRestoreWorkspacesTabOnNavigate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,23 @@ describe('useRestoreWorkspacesTabOnNavigate', () => {
lastVisitedTabPathUtils.getWorkspacesTabStateFromSessionStorage.mockReturnValue({
routes: [
{
name: NAVIGATORS.WORKSPACE_NAVIGATOR,
name: NAVIGATORS.TAB_NAVIGATOR,
state: {
routes: [
{
name: NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR,
name: NAVIGATORS.WORKSPACE_NAVIGATOR,
state: {
index: 1,
routes: [
{name: SCREENS.WORKSPACE.INITIAL, params: {policyID: fakePolicyID}},
{name: SCREENS.WORKSPACE.WORKFLOWS, params: {policyID: fakePolicyID}},
{
name: NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR,
state: {
index: 1,
routes: [
{name: SCREENS.WORKSPACE.INITIAL, params: {policyID: fakePolicyID}},
{name: SCREENS.WORKSPACE.WORKFLOWS, params: {policyID: fakePolicyID}},
],
},
},
],
},
},
Expand Down
Loading