File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
apps/sim/app/workspace/[workspaceId]/w/hooks Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,18 @@ export function useDeleteWorkflow({
7878
7979 // Find next workflow to navigate to (if active workflow is being deleted)
8080 const sidebarWorkflows = Object . values ( workflows ) . filter ( ( w ) => w . workspaceId === workspaceId )
81- const firstWorkflowId = workflowIdsToDelete [ 0 ]
82- const currentIndex = sidebarWorkflows . findIndex ( ( w ) => w . id === firstWorkflowId )
81+
82+ // Find which specific workflow is the active one (if any in the deletion list)
83+ let activeWorkflowId : string | null = null
84+ if ( isActiveWorkflowBeingDeleted && typeof isActive === 'function' ) {
85+ // Check each workflow being deleted to find which one is active
86+ activeWorkflowId =
87+ workflowIdsToDelete . find ( ( id ) => isActive ( [ id ] ) ) || workflowIdsToDelete [ 0 ]
88+ } else {
89+ activeWorkflowId = workflowIdsToDelete [ 0 ]
90+ }
91+
92+ const currentIndex = sidebarWorkflows . findIndex ( ( w ) => w . id === activeWorkflowId )
8393
8494 let nextWorkflowId : string | null = null
8595 if ( isActiveWorkflowBeingDeleted && sidebarWorkflows . length > workflowIdsToDelete . length ) {
You can’t perform that action at this time.
0 commit comments