feat(mobile): context menu triggering

This commit is contained in:
Elian Doran 2024-12-28 09:50:19 +02:00
parent 0eca95cecb
commit 1eecf9a5c8
No known key found for this signature in database
2 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { CommandNames } from '../components/app_context.js';
import keyboardActionService from '../services/keyboard_actions.js';
import utils from '../services/utils.js';
interface ContextMenuOptions<T extends CommandNames> {
x: number;
@ -34,13 +35,21 @@ class ContextMenu {
private $widget!: JQuery<HTMLElement>;
private dateContextMenuOpenedMs: number;
private options?: ContextMenuOptions<any>;
private isMobile: boolean;
constructor() {
this.$widget = $("#context-menu-container");
this.$widget.addClass("dropend");
this.dateContextMenuOpenedMs = 0;
this.isMobile = utils.isMobile();
$(document).on('click', () => this.hide());
$(document).on('click', (e) => {
if (this.isMobile && $(e.target).closest("#context-menu-container").length) {
return;
}
this.hide();
});
}
async show<T extends CommandNames>(options: ContextMenuOptions<T>) {
@ -158,6 +167,16 @@ class ContextMenu {
return false;
}
if (this.isMobile && "items" in item && item.items) {
const $target = $(e.target);
$target
.parents(".dropdown-item")
.find("ul.dropdown-menu")
.toggleClass("show");
e.preventDefault();
return false;
}
this.hide();
if ("handler" in item && item.handler) {

View File

@ -966,7 +966,7 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
cursor: pointer;
}
li.dropdown-submenu:hover > ul.dropdown-menu {
body.desktop li.dropdown-submenu:hover > ul.dropdown-menu {
display: block;
}