...
This commit is contained in:
@@ -92,29 +92,24 @@ function hideContextMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
// Context menu item click handler
|
||||
// Combined click handler for context menu and outside clicks
|
||||
document.addEventListener('click', async (e) => {
|
||||
const menuItem = e.target.closest('.context-menu-item');
|
||||
if (!menuItem) {
|
||||
hideContextMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
const action = menuItem.dataset.action;
|
||||
const menu = document.getElementById('contextMenu');
|
||||
const targetPath = menu.dataset.targetPath;
|
||||
const isDir = menu.dataset.targetIsDir === 'true';
|
||||
|
||||
hideContextMenu();
|
||||
|
||||
if (window.fileTreeActions) {
|
||||
await window.fileTreeActions.execute(action, targetPath, isDir);
|
||||
}
|
||||
});
|
||||
if (menuItem) {
|
||||
// Handle context menu item click
|
||||
const action = menuItem.dataset.action;
|
||||
const menu = document.getElementById('contextMenu');
|
||||
const targetPath = menu.dataset.targetPath;
|
||||
const isDir = menu.dataset.targetIsDir === 'true';
|
||||
|
||||
// Hide on outside click
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!e.target.closest('#contextMenu') && !e.target.closest('.tree-node')) {
|
||||
hideContextMenu();
|
||||
|
||||
if (window.fileTreeActions) {
|
||||
await window.fileTreeActions.execute(action, targetPath, isDir);
|
||||
}
|
||||
} else if (!e.target.closest('#contextMenu') && !e.target.closest('.tree-node')) {
|
||||
// Hide on outside click
|
||||
hideContextMenu();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user