WebUI: Do not hide context menu if the click target has submenu

Add check if the click event occurs in the menu item and if the menu item has a submenu, do not close the context menu.

Closes #23532.
PR #23534.
This commit is contained in:
Mark Yu
2025-11-30 06:15:23 -05:00
committed by GitHub
parent 296c90d688
commit 8b9064a33c

View File

@@ -211,6 +211,18 @@ window.qBittorrent.ContextMenu ??= (() => {
// hide on body click
document.body.addEventListener("click", (event) => {
const parentNode = event.target.parentNode;
// make sure the click was on a context menu item
if ((parentNode !== null) && (parentNode.tagName.toLowerCase() === "li")) {
const grandParentNode = parentNode.parentNode;
if ((grandParentNode !== null) && (grandParentNode.classList.contains("contextMenu"))) {
const submenuNodes = parentNode.getElementsByTagName("ul");
if (submenuNodes.length > 0)
return;
}
}
this.hide();
this.options.element = null;
});