This commit is contained in:
2025-10-26 09:15:51 +04:00
parent b9349425d7
commit cae90ec3dc
3 changed files with 55 additions and 77 deletions

View File

@@ -39,13 +39,17 @@ class FileTree {
// Context menu
this.container.addEventListener('contextmenu', (e) => {
const node = e.target.closest('.tree-node');
if (!node) return;
e.preventDefault();
const path = node.dataset.path;
const isDir = node.dataset.isdir === 'true';
window.showContextMenu(e.clientX, e.clientY, { path, isDir });
if (node) {
// Clicked on a node
const path = node.dataset.path;
const isDir = node.dataset.isdir === 'true';
window.showContextMenu(e.clientX, e.clientY, { path, isDir });
} else if (e.target === this.container) {
// Clicked on the empty space in the file tree container
window.showContextMenu(e.clientX, e.clientY, { path: '', isDir: true });
}
});
}