Skip to content

Commit 0fb2f7c

Browse files
icecrasher321Vikhyath Mondreti
andauthored
fix switch workspace bug (#560)
Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@Vikhyaths-Air.attlocal.net>
1 parent 1a71947 commit 0fb2f7c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,11 @@ export const WorkspaceHeader = React.memo<WorkspaceHeaderProps>(
343343
setActiveWorkspace(workspace)
344344
setWorkspaceDropdownOpen(false)
345345

346-
// Use full workspace switch which now handles localStorage automatically
347-
switchToWorkspace(workspace.id)
348-
349-
// Update URL to include workspace ID
346+
// Update URL first so sidebar filters use the new workspace ID
350347
router.push(`/workspace/${workspace.id}/w`)
348+
349+
// Then switch workspace which will clear workflows and fetch new ones
350+
switchToWorkspace(workspace.id)
351351
},
352352
[activeWorkspace?.id, switchToWorkspace, router, setWorkspaceDropdownOpen]
353353
)
@@ -372,12 +372,11 @@ export const WorkspaceHeader = React.memo<WorkspaceHeaderProps>(
372372
setWorkspaces((prev) => [...prev, newWorkspace])
373373
setActiveWorkspace(newWorkspace)
374374

375-
// Use switchToWorkspace to properly load workflows for the new workspace
376-
// This will clear existing workflows, set loading state, and fetch workflows from DB
377-
switchToWorkspace(newWorkspace.id)
378-
379-
// Update URL to include new workspace ID
375+
// Update URL first so sidebar filters use the new workspace ID
380376
router.push(`/workspace/${newWorkspace.id}/w`)
377+
378+
// Then switch workspace which will clear workflows and fetch new ones
379+
switchToWorkspace(newWorkspace.id)
381380
}
382381
} catch (err) {
383382
logger.error('Error creating workspace:', err)

0 commit comments

Comments
 (0)