Skip to content

Commit a2df89e

Browse files
committed
optimized
1 parent e350a9c commit a2df89e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useCallback, useEffect, useMemo } from 'react'
3+
import { memo, useCallback, useEffect, useMemo } from 'react'
44
import clsx from 'clsx'
55
import { useParams, usePathname } from 'next/navigation'
66
import { FolderItem } from '@/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item'
@@ -26,7 +26,13 @@ interface WorkflowListProps {
2626
scrollContainerRef: React.RefObject<HTMLDivElement | null>
2727
}
2828

29-
function DropIndicatorLine({ show, level = 0 }: { show: boolean; level?: number }) {
29+
const DropIndicatorLine = memo(function DropIndicatorLine({
30+
show,
31+
level = 0,
32+
}: {
33+
show: boolean
34+
level?: number
35+
}) {
3036
if (!show) return null
3137
return (
3238
<div
@@ -36,7 +42,7 @@ function DropIndicatorLine({ show, level = 0 }: { show: boolean; level?: number
3642
<div className='h-[2px] flex-1 rounded-full bg-[#33b4ff]/70' />
3743
</div>
3844
)
39-
}
45+
})
4046

4147
export function WorkflowList({
4248
regularWorkflows,

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-drag-drop.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,10 @@ export function useDragDrop() {
506506
(folderId: string) => ({
507507
onDragOver: (e: React.DragEvent<HTMLElement>) => {
508508
e.preventDefault()
509-
e.stopPropagation() // Prevent bubbling to root when in gaps between items
509+
e.stopPropagation()
510510
lastDragYRef.current = e.clientY
511511
setIsDragging(true)
512-
// Only set folder highlight if dragging from a different folder
513-
if (draggedSourceFolderRef.current !== folderId) {
512+
if (e.target === e.currentTarget && draggedSourceFolderRef.current !== folderId) {
514513
setNormalizedDropIndicator({ targetId: folderId, position: 'inside', folderId: null })
515514
}
516515
},
@@ -523,7 +522,9 @@ export function useDragDrop() {
523522
() => ({
524523
onDragOver: (e: React.DragEvent<HTMLElement>) => {
525524
initDragOver(e, false)
526-
setNormalizedDropIndicator({ targetId: 'root', position: 'inside', folderId: null })
525+
if (e.target === e.currentTarget) {
526+
setNormalizedDropIndicator({ targetId: 'root', position: 'inside', folderId: null })
527+
}
527528
},
528529
onDragLeave: (e: React.DragEvent<HTMLElement>) => {
529530
if (isLeavingElement(e)) setNormalizedDropIndicator(null)

0 commit comments

Comments
 (0)