Fix same-window folder drop target detection
This commit is contained in:
+14
-4
@@ -2283,16 +2283,17 @@ async function finishItemPointerDrag(event, move, up) {
|
||||
if (!drag) return;
|
||||
|
||||
markDraggingRows(drag.paths, false);
|
||||
state.pointerDrag = null;
|
||||
|
||||
if (!drag.active) {
|
||||
state.pointerDrag = null;
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
state.suppressClickPath = drag.path;
|
||||
state.suppressItemActivationUntil = Date.now() + 450;
|
||||
const target = findPointerDropTarget(event);
|
||||
const target = findPointerDropTarget(event, drag);
|
||||
state.pointerDrag = null;
|
||||
recordDebug('pointer.finish', {
|
||||
source: drag.path,
|
||||
sources: drag.paths,
|
||||
@@ -2378,7 +2379,7 @@ function clearPointerDropTarget() {
|
||||
}
|
||||
}
|
||||
|
||||
function findPointerDropTarget(event) {
|
||||
function findPointerDropTarget(event, drag = state.pointerDrag) {
|
||||
let element;
|
||||
let elements = [];
|
||||
try {
|
||||
@@ -2404,16 +2405,22 @@ function findPointerDropTarget(event) {
|
||||
const win = state.windows.find((item) => item.id === windowEl.dataset.windowId);
|
||||
if (!win || win.kind !== 'explorer') return null;
|
||||
|
||||
const drag = state.pointerDrag;
|
||||
let row = null;
|
||||
let overEntry = false;
|
||||
for (const candidate of elements) {
|
||||
try {
|
||||
const treeTarget = candidate.closest?.('.tree-label[data-tree-open]');
|
||||
if (treeTarget && treeTarget.closest?.('.window') === windowEl) {
|
||||
overEntry = true;
|
||||
}
|
||||
if (treeTarget && treeTarget.closest?.('.window') === windowEl && isValidPointerTargetPath(treeTarget.dataset.treeOpen, drag)) {
|
||||
row = treeTarget;
|
||||
break;
|
||||
}
|
||||
const candidateRow = candidate.closest?.('.file-row');
|
||||
if (candidateRow && candidateRow.closest?.('.window') === windowEl) {
|
||||
overEntry = true;
|
||||
}
|
||||
if (!candidateRow || candidateRow.dataset.type !== 'directory') {
|
||||
continue;
|
||||
}
|
||||
@@ -2435,6 +2442,9 @@ function findPointerDropTarget(event) {
|
||||
if (row) {
|
||||
return { windowId: win.id, path: row.dataset.path || row.dataset.treeOpen, row };
|
||||
}
|
||||
if (overEntry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { windowId: win.id, path: win.data.path, row: null };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user