fix: close context menu when clicking items with submenus

This commit is contained in:
SiriusXT 2025-09-07 17:15:09 +08:00
parent 7f3c34178b
commit 2f93af4d6f

View File

@ -62,7 +62,7 @@ class ContextMenu {
if (this.isMobile) {
this.$cover.on("click", () => this.hide());
} else {
$(document).on("click", (e) => this.hide());
$(document).on("mouseup", (e) => this.hide());
}
}
@ -225,9 +225,10 @@ class ContextMenu {
$item.on("mouseup", (e) => {
// Prevent submenu from failing to expand on mobile
if (!this.isMobile || !("items" in item && item.items)) {
e.stopPropagation();
// Hide the content menu on mouse up to prevent the mouse event from propagating to the elements below.
this.hide();
if (("command" in item) || ("handler" in item)) {
this.hide();
}
return false;
}
});