From fa9e765e372779b45d337a8c7d6bc1a37969f219 Mon Sep 17 00:00:00 2001 From: shancds Date: Mon, 7 Jul 2025 17:20:34 +0530 Subject: [PATCH] refactor(KanbanGroup, TaskCard): enhance drag-and-drop indicators and task rendering - Added visual drop indicators before and after task cards in the KanbanGroup component to improve user experience during drag-and-drop operations. - Removed the isDropIndicator prop from TaskCard as the drop indicator logic is now handled within the KanbanGroup, simplifying the TaskCard component. - Updated drag-and-drop event handling in TaskCard to better manage task positioning during drag operations, enhancing overall functionality. --- .../KanbanGroup.tsx | 32 +++++++++++++------ .../EnhancedKanbanBoardNativeDnD/TaskCard.tsx | 27 ++++++---------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/KanbanGroup.tsx b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/KanbanGroup.tsx index d5e814ba..0e3e8a6d 100644 --- a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/KanbanGroup.tsx +++ b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/KanbanGroup.tsx @@ -517,17 +517,29 @@ const KanbanGroup: React.FC = memo(({ )} {group.tasks.map((task, idx) => ( - + + {/* Drop indicator before this card */} + {hoveredGroupId === group.id && hoveredTaskIdx === idx && ( +
+
+
+ )} + + ))} + {/* Drop indicator at the end of the group */} + {hoveredGroupId === group.id && hoveredTaskIdx === group.tasks.length && ( +
+
+
+ )} {/* Create card at bottom */} {showNewCardBottom && ( diff --git a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/TaskCard.tsx b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/TaskCard.tsx index e6b855fb..0a503ba2 100644 --- a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/TaskCard.tsx +++ b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanBoardNativeDnD/TaskCard.tsx @@ -28,7 +28,6 @@ interface TaskCardProps { onTaskDragOver: (e: React.DragEvent, groupId: string, taskIdx: number) => void; onTaskDrop: (e: React.DragEvent, groupId: string, taskIdx: number) => void; groupId: string; - isDropIndicator: boolean; idx: number; } @@ -46,7 +45,6 @@ const TaskCard: React.FC = memo(({ onTaskDragOver, onTaskDrop, groupId, - isDropIndicator, idx }) => { const { socket } = useSocket(); @@ -198,29 +196,22 @@ const TaskCard: React.FC = memo(({ while (week.length < 7) week.push(null); weeks.push(week); } + const [isDown, setIsDown] = useState(false); return ( <> - {isDropIndicator && ( -
onTaskDragStart(e, task.id!, groupId)} - onDragOver={e => onTaskDragOver(e, groupId, idx)} - onDrop={e => onTaskDrop(e, groupId, idx)} - > -
-
- )}
onTaskDragStart(e, task.id!, groupId)} - onDragOver={e => onTaskDragOver(e, groupId, idx)} + onDragOver={e => { + e.preventDefault(); + const rect = e.currentTarget.getBoundingClientRect(); + const offsetY = e.clientY - rect.top; + const isDown = offsetY > rect.height / 2; + setIsDown(isDown); + onTaskDragOver(e, groupId, isDown ? idx + 1 : idx); + }} onDrop={e => onTaskDrop(e, groupId, idx)} onClick={e => handleCardClick(e, task.id!)}