Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix drag and drop bug in task columns (#96)

Yuvraj Rathodf2fed79377b8
diff --git a/apps/web/src/components/kanban-board/index.tsx b/apps/web/src/components/kanban-board/index.tsx
index 93a3e7f24..4c694904c 100644
--- a/apps/web/src/components/kanban-board/index.tsx
+++ b/apps/web/src/components/kanban-board/index.tsx
@@ -58,9 +58,12 @@ function KanbanBoard() {
sourceColumn.tasks = sourceColumn.tasks.filter((t) => t.id !== activeId);
if (sourceColumn.id === destinationColumn.id) {
- const destinationIndex = destinationColumn.tasks.findIndex(
+ let destinationIndex = destinationColumn.tasks.findIndex(
(t) => t.id === overId,
);
+ if (sourceTaskIndex <= destinationIndex) {
+ destinationIndex += 1;
+ }
destinationColumn.tasks.splice(destinationIndex, 0, task);
} else {
const updatedTask = { ...task, status: destinationColumn.id };
@@ -71,7 +74,7 @@ function KanbanBoard() {
? destinationColumn.tasks.length
: destinationColumn.tasks.findIndex((t) => t.id === overId);
- destinationColumn.tasks.splice(destinationIndex, 0, updatedTask);
+ destinationColumn.tasks.splice(destinationIndex + 1, 0, updatedTask);
}
});