Skip to content

Commit 08bc112

Browse files
authored
fix(cmd-k): when navigating to current workspace/workflow, close modal instead of navigating (#2420)
* fix(cmd-k): when navigating to current workspace, close modal instead of navigating * ack PR comment
1 parent f4f74da commit 08bc112

File tree

1 file changed

+14
-6
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal

1 file changed

+14
-6
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,20 +423,28 @@ export function SearchModal({
423423
}
424424
break
425425
case 'workspace':
426+
if (item.isCurrent) {
427+
break
428+
}
429+
if (item.href) {
430+
router.push(item.href)
431+
}
432+
break
426433
case 'workflow':
434+
if (!item.isCurrent && item.href) {
435+
router.push(item.href)
436+
window.dispatchEvent(
437+
new CustomEvent(SIDEBAR_SCROLL_EVENT, { detail: { itemId: item.id } })
438+
)
439+
}
440+
break
427441
case 'page':
428442
case 'doc':
429443
if (item.href) {
430444
if (item.href.startsWith('http')) {
431445
window.open(item.href, '_blank', 'noopener,noreferrer')
432446
} else {
433447
router.push(item.href)
434-
// Scroll to the workflow in the sidebar after navigation
435-
if (item.type === 'workflow') {
436-
window.dispatchEvent(
437-
new CustomEvent(SIDEBAR_SCROLL_EVENT, { detail: { itemId: item.id } })
438-
)
439-
}
440448
}
441449
}
442450
break

0 commit comments

Comments
 (0)