forked from ComputerTech/aprhodite
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
|
||||
const newMenu = contextMenu.cloneNode(true);
|
||||
contextMenu.replaceWith(newMenu);
|
||||
|
||||
// Add new listeners
|
||||
newMenu.querySelectorAll(".menu-item").forEach(item => {
|
||||
// Store target for click handler (uses event delegation below)
|
||||
contextMenu._targetUser = user.username;
|
||||
|
||||
// Remove old inline onclick handlers and re-bind
|
||||
contextMenu.querySelectorAll(".menu-item").forEach(item => {
|
||||
item.onclick = () => {
|
||||
const action = item.dataset.action;
|
||||
executeMenuAction(action, user.username);
|
||||
newMenu.classList.add("hidden");
|
||||
executeMenuAction(action, contextMenu._targetUser);
|
||||
contextMenu.classList.add("hidden");
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue