fix: file not linking to note when uploaded by dragging on note
This commit is contained in:
@@ -166,6 +166,12 @@ const FileDragNDropProvider = ({ application, children, featuresController, file
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
||||||
|
let closestDragTarget: Element | null = null
|
||||||
|
|
||||||
|
if (event.target instanceof HTMLElement) {
|
||||||
|
closestDragTarget = event.target.closest('[data-file-drag-target]')
|
||||||
|
}
|
||||||
|
|
||||||
resetState()
|
resetState()
|
||||||
|
|
||||||
if (!featuresController.hasFiles) {
|
if (!featuresController.hasFiles) {
|
||||||
@@ -189,12 +195,6 @@ const FileDragNDropProvider = ({ application, children, featuresController, file
|
|||||||
return
|
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)) {
|
if (closestDragTarget && dragTargets.current.has(closestDragTarget)) {
|
||||||
dragTargets.current.get(closestDragTarget)?.callback(uploadedFiles)
|
dragTargets.current.get(closestDragTarget)?.callback(uploadedFiles)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement }: Pr
|
|||||||
if (target) {
|
if (target) {
|
||||||
addDragTarget(target, {
|
addDragTarget(target, {
|
||||||
tooltipText: 'Drop your files to upload and link them to the current note',
|
tooltipText: 'Drop your files to upload and link them to the current note',
|
||||||
callback(files) {
|
callback: (files) => {
|
||||||
files.forEach(async (uploadedFile) => {
|
files.forEach(async (uploadedFile) => {
|
||||||
await linkingController.linkItems(uploadedFile, note)
|
await linkingController.linkItems(note, uploadedFile)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user