Suppress item activation after drag drop

This commit is contained in:
Mikei386
2026-06-23 12:11:06 +02:00
parent 50c685ee80
commit 9b12e0d150
5 changed files with 18 additions and 4 deletions
+15 -1
View File
@@ -13,6 +13,7 @@ const state = {
draggedEntry: null,
pointerDrag: null,
suppressClickPath: null,
suppressItemActivationUntil: 0,
debug: [],
nextDebugId: 1,
jobs: new Map(),
@@ -276,8 +277,12 @@ function renderExplorer(body, win) {
lockExplorerScroll(win, body);
startItemPointerDrag(event, win, entry);
});
row.addEventListener('click', () => selectEntry(win, entry, body));
row.addEventListener('click', () => {
if (shouldSuppressItemActivation()) return;
selectEntry(win, entry, body);
});
row.addEventListener('dblclick', () => {
if (shouldSuppressItemActivation()) return;
if (entry.type === 'directory') {
loadExplorer(win, entry.path);
}
@@ -785,6 +790,14 @@ function selectEntry(win, entry, scrollBody = null) {
restoreExplorerScroll(win, scrollBody);
}
function shouldSuppressItemActivation() {
if (Date.now() <= state.suppressItemActivationUntil) {
recordDebug('item.activation.suppressed', { until: state.suppressItemActivationUntil });
return true;
}
return false;
}
function focusWindow(win) {
state.focusedId = win.id;
win.zIndex = ++state.zIndex;
@@ -879,6 +892,7 @@ async function finishItemPointerDrag(event, move, up) {
event.preventDefault();
state.suppressClickPath = drag.path;
state.suppressItemActivationUntil = Date.now() + 450;
const target = findPointerDropTarget(event);
recordDebug('pointer.finish', {
source: drag.path,