Suppress item activation after drag drop
This commit is contained in:
+15
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user