Skip to content

Build your personal knowledge base with Trilium Notes

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

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