Dev #2
@@ -579,8 +579,25 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
|||||||
await persistDocument(updatedDoc);
|
await persistDocument(updatedDoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Global drag cleanup so drag states never get stuck if dragend is lost during re-render
|
||||||
|
useEffect(() => {
|
||||||
|
const handleGlobalDragEnd = () => {
|
||||||
|
setDraggingDocId(null);
|
||||||
|
setDragOverFolder(null);
|
||||||
|
setDraggingBlockId(null);
|
||||||
|
};
|
||||||
|
window.addEventListener('dragend', handleGlobalDragEnd);
|
||||||
|
window.addEventListener('drop', handleGlobalDragEnd);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('dragend', handleGlobalDragEnd);
|
||||||
|
window.removeEventListener('drop', handleGlobalDragEnd);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleDropDocToFolder = async (folderPath: string, e: React.DragEvent) => {
|
const handleDropDocToFolder = async (folderPath: string, e: React.DragEvent) => {
|
||||||
const docId = e.dataTransfer.getData('application/mindsift-doc-id') || draggingDocId;
|
const docId = e.dataTransfer.getData('application/mindsift-doc-id') || draggingDocId;
|
||||||
|
setDraggingDocId(null);
|
||||||
|
setDragOverFolder(null);
|
||||||
if (!docId) return;
|
if (!docId) return;
|
||||||
const doc = docs.find((d) => d.id === docId);
|
const doc = docs.find((d) => d.id === docId);
|
||||||
if (!doc) return;
|
if (!doc) return;
|
||||||
@@ -1244,6 +1261,7 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setDragOverFolder(null);
|
setDragOverFolder(null);
|
||||||
|
setDraggingDocId(null);
|
||||||
handleDropDocToFolder(node.path, e);
|
handleDropDocToFolder(node.path, e);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -1532,6 +1550,7 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setDragOverFolder(null);
|
setDragOverFolder(null);
|
||||||
|
setDraggingDocId(null);
|
||||||
handleDropDocToFolder('', e);
|
handleDropDocToFolder('', e);
|
||||||
}}
|
}}
|
||||||
className={`mx-2 my-1.5 p-2 border-2 border-dashed rounded-btn text-center text-xs transition-colors ${
|
className={`mx-2 my-1.5 p-2 border-2 border-dashed rounded-btn text-center text-xs transition-colors ${
|
||||||
|
|||||||
Reference in new issue
Block a user