mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
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:
@@ -211,6 +211,18 @@ window.qBittorrent.ContextMenu ??= (() => {
|
|||||||
|
|
||||||
// hide on body click
|
// hide on body click
|
||||||
document.body.addEventListener("click", (event) => {
|
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.hide();
|
||||||
this.options.element = null;
|
this.options.element = null;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user