fix: file not linking to note when uploaded by dragging on note

This commit is contained in:
Aman Harwara
2022-10-20 12:44:50 +05:30
parent e99c7b7c51
commit d333d4f188
2 changed files with 8 additions and 8 deletions

View File

@@ -166,6 +166,12 @@ const FileDragNDropProvider = ({ application, children, featuresController, file
event.preventDefault()
event.stopPropagation()
let closestDragTarget: Element | null = null
if (event.target instanceof HTMLElement) {
closestDragTarget = event.target.closest('[data-file-drag-target]')
}
resetState()
if (!featuresController.hasFiles) {
@@ -189,12 +195,6 @@ const FileDragNDropProvider = ({ application, children, featuresController, file
return
}
let closestDragTarget: Element | null = null
if (event.target instanceof HTMLElement) {
closestDragTarget = event.target.closest('[data-file-drag-target]')
}
if (closestDragTarget && dragTargets.current.has(closestDragTarget)) {
dragTargets.current.get(closestDragTarget)?.callback(uploadedFiles)
}

View File

@@ -18,9 +18,9 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement }: Pr
if (target) {
addDragTarget(target, {
tooltipText: 'Drop your files to upload and link them to the current note',
callback(files) {
callback: (files) => {
files.forEach(async (uploadedFile) => {
await linkingController.linkItems(uploadedFile, note)
await linkingController.linkItems(note, uploadedFile)
})
},
})