Set isDragging to false when dragging ends

This commit is contained in:
haecheonlee 2024-04-16 22:30:47 -04:00
parent aed1882165
commit 8f659eb975

View File

@ -24,6 +24,7 @@ export default function TableInfo({ data }) {
const [editField, setEditField] = useState({});
const draggingElementIndex = useRef();
const isDragging = useRef();
console.log(isDragging.current);
return (
<div>
@ -62,6 +63,7 @@ export default function TableInfo({ data }) {
onDragOver={(e) => {
e.preventDefault();
if (isDragging.current) return;
console.log("dragging over...");
isDragging.current = true;
draggingElementIndex.current = j;
}}
@ -80,6 +82,10 @@ export default function TableInfo({ data }) {
updateField(data.id, index, { ...b, id: index });
updateField(data.id, j, { ...a, id: j });
}}
onDragEnd={(e) => {
e.preventDefault();
isDragging.current = false;
}}
>
<TableField data={f} tid={data.id} index={j} />
</div>