From 5051f1f460f5d64c81f88722763a9c32f1c44860 Mon Sep 17 00:00:00 2001 From: sosokker Date: Thu, 23 Nov 2023 12:39:09 +0700 Subject: [PATCH 1/5] Make Column undruggable --- .../kanbanBoard/columnContainer.jsx | 93 +++++-------------- .../kanbanBoard/columnContainerWrapper.jsx | 6 +- .../components/kanbanBoard/kanbanBoard.jsx | 92 +++++------------- .../components/navigations/IconSideNav.jsx | 4 +- 4 files changed, 47 insertions(+), 148 deletions(-) diff --git a/frontend/src/components/kanbanBoard/columnContainer.jsx b/frontend/src/components/kanbanBoard/columnContainer.jsx index 819a980..5b9648e 100644 --- a/frontend/src/components/kanbanBoard/columnContainer.jsx +++ b/frontend/src/components/kanbanBoard/columnContainer.jsx @@ -1,53 +1,31 @@ import { SortableContext, useSortable } from "@dnd-kit/sortable"; -import { BsFillTrashFill } from "react-icons/bs"; import { AiOutlinePlusCircle } from "react-icons/ai"; -import { CSS } from "@dnd-kit/utilities"; -import { useMemo, useState } from "react"; +import { useMemo } from "react"; import { TaskCard } from "./taskCard"; -export function ColumnContainer({ column, deleteColumn, updateColumn, createTask, tasks, deleteTask, updateTask }) { - const [editMode, setEditMode] = useState(false); - +export function ColumnContainer({ column, createTask, tasks, deleteTask, updateTask }) { const tasksIds = useMemo(() => { return tasks.map((task) => task.id); }, [tasks]); - const { setNodeRef, attributes, listeners, transform, transition, isDragging } = useSortable({ + const { + setNodeRef: columnNodeRef, + attributes: columnAttributes, + listeners: columnListeners, + } = useSortable({ id: column.id, data: { type: "Column", column, }, - disabled: editMode, + disabled: true, // Disable drag for the entire column }); - const style = { - transition, - transform: CSS.Transform.toString(transform), - }; - - if (isDragging) { - return ( -
- ); - } - return (
{/* Column title */}
{ - setEditMode(true); - }} className=" ml-3 text-md - cursor-grab font-bold flex items-center justify-between "> -
- {!editMode && column.title} - {editMode && ( - updateColumn(column.id, e.target.value)} - autoFocus - onBlur={() => { - setEditMode(false); - }} - onKeyDown={(e) => { - if (e.key !== "Enter") return; - setEditMode(false); - }} - /> - )} -
- +
{column.title}
{/* Column task container */}
{tasks.map((task) => ( - + useSortable({ ...props, disabled: false })} + /> ))}
+ {/* Column footer */}