fix(editor): prevent file upload overlay when dragging text from editor (#2148)

Fixes the file upload overlay incorrectly appearing when dragging text from within the TipTap description editor to outside of it.

Fixes #1663
This commit is contained in:
kolaente
2026-01-24 18:41:42 +01:00
committed by GitHub
parent 5050cd7162
commit 1731b03c22

View File

@@ -245,12 +245,29 @@ function resetDragState() {
isDragOverEditor.value = false
}
/**
* Check if a drag event contains actual files (not text being dragged).
* This prevents the file upload overlay from appearing when dragging text
* from within the editor to outside it.
*/
function eventContainsFiles(event: Event | null | undefined): boolean {
if (!event || !(event instanceof DragEvent)) {
return false
}
return event.dataTransfer?.types.includes('Files') ?? false
}
const {isOverDropZone} = useDropZone(document, {
onEnter(files, event) {
if (!props.editEnabled) {
return
}
// Only show dropzone if actual files are being dragged, not text
if (!eventContainsFiles(event)) {
return
}
isDraggingFiles.value = true
isDragOverEditor.value = eventTargetsEditor(event)
},