From 8b9064a33cca1dfbb8bf72cbacbec69280e8b514 Mon Sep 17 00:00:00 2001 From: Mark Yu Date: Sun, 30 Nov 2025 06:15:23 -0500 Subject: [PATCH] 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. --- src/webui/www/private/scripts/contextmenu.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/webui/www/private/scripts/contextmenu.js b/src/webui/www/private/scripts/contextmenu.js index 339dc6466..ce6c3756e 100644 --- a/src/webui/www/private/scripts/contextmenu.js +++ b/src/webui/www/private/scripts/contextmenu.js @@ -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; });