diff --git a/src/public/app/menus/context_menu.ts b/src/public/app/menus/context_menu.ts index 54140d9ea..e765728e7 100644 --- a/src/public/app/menus/context_menu.ts +++ b/src/public/app/menus/context_menu.ts @@ -32,25 +32,24 @@ export type MenuHandler = (item: MenuCommandItem, e: class ContextMenu { - private $widget!: JQuery; + private $widget: JQuery; + private $cover: JQuery; private dateContextMenuOpenedMs: number; private options?: ContextMenuOptions; private isMobile: boolean; constructor() { this.$widget = $("#context-menu-container"); + this.$cover = $("#context-menu-cover"); this.$widget.addClass("dropend"); this.dateContextMenuOpenedMs = 0; this.isMobile = utils.isMobile(); - $(document).on('click', (e) => { - if (this.isMobile && $(e.target).closest("#context-menu-container").length) { - return; - } - - console.log("Hide from ", e.target); - this.hide(); - }); + if (this.isMobile) { + this.$cover.on("click", this.hide); + } else { + $(document).on('click', (e) => this.hide); + } } async show(options: ContextMenuOptions) { @@ -62,6 +61,8 @@ class ContextMenu { await this.hide(); } + this.$cover.addClass("show"); + this.$widget.empty(); this.addItems(this.$widget, options.items); @@ -223,7 +224,8 @@ class ContextMenu { // see https://github.com/zadam/trilium/pull/3805 for details await timeout(100); this.$widget.removeClass("show"); - this.$widget.hide() + this.$cover.removeClass("show"); + this.$widget.hide(); } } } diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index bba7b3afa..10c85b1d5 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -954,6 +954,16 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href cursor: row-resize; } +#context-menu-cover.show { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1000; + background: rgba(0, 0, 0, 0.1); +} + #context-menu-container { max-height: 100vh; /* !!! Cannot set overflow: auto, submenus will break !!! */ diff --git a/src/views/mobile.ejs b/src/views/mobile.ejs index b39617db6..aa401bd24 100644 --- a/src/views/mobile.ejs +++ b/src/views/mobile.ejs @@ -100,6 +100,8 @@
+
+