fix(context_menu): toggling submenu hides the menu most of the time

This commit is contained in:
Elian Doran 2025-11-26 20:35:02 +02:00
parent 706da768e2
commit d2d7fd7c4c
No known key found for this signature in database

View File

@ -298,8 +298,6 @@ class ContextMenu {
// important to use mousedown instead of click since the former does not change focus // important to use mousedown instead of click since the former does not change focus
// (especially important for focused text for spell check) // (especially important for focused text for spell check)
.on("mousedown", (e) => { .on("mousedown", (e) => {
e.stopPropagation();
if (e.which !== 1) { if (e.which !== 1) {
// only left click triggers menu items // only left click triggers menu items
return false; return false;
@ -313,6 +311,11 @@ class ContextMenu {
return false; return false;
} }
// Prevent submenu from failing to expand on mobile
if (!("items" in item && item.items)) {
this.hide();
}
if ("handler" in item && item.handler) { if ("handler" in item && item.handler) {
item.handler(item, e); item.handler(item, e);
} }
@ -324,16 +327,6 @@ class ContextMenu {
return false; return false;
}); });
$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();
return false;
}
});
if ("enabled" in item && item.enabled !== undefined && !item.enabled) { if ("enabled" in item && item.enabled !== undefined && !item.enabled) {
$item.addClass("disabled"); $item.addClass("disabled");
} }