Fix #9: Fix context menu breaking after first use
- Remove cloneNode/replaceWith pattern that orphaned the reference - Re-bind onclick handlers directly on the existing DOM node - Context menu now works reliably on every right-click
This commit is contained in:
parent
b38eb01e27
commit
496701c713
|
|
@ -528,16 +528,15 @@ function showContextMenu(e, user) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cleanup previous listeners
|
// Store target for click handler (uses event delegation below)
|
||||||
const newMenu = contextMenu.cloneNode(true);
|
contextMenu._targetUser = user.username;
|
||||||
contextMenu.replaceWith(newMenu);
|
|
||||||
|
|
||||||
// Add new listeners
|
// Remove old inline onclick handlers and re-bind
|
||||||
newMenu.querySelectorAll(".menu-item").forEach(item => {
|
contextMenu.querySelectorAll(".menu-item").forEach(item => {
|
||||||
item.onclick = () => {
|
item.onclick = () => {
|
||||||
const action = item.dataset.action;
|
const action = item.dataset.action;
|
||||||
executeMenuAction(action, user.username);
|
executeMenuAction(action, contextMenu._targetUser);
|
||||||
newMenu.classList.add("hidden");
|
contextMenu.classList.add("hidden");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue