Skip to content

Build your personal knowledge base with Trilium Notes

feat(collections/calendar): change click behaviour on mobile

Elian Doranc4a426566f12
diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsx
index 39b9ad6bbf..493640d25c 100644
--- a/apps/client/src/widgets/collections/calendar/index.tsx
+++ b/apps/client/src/widgets/collections/calendar/index.tsx
@@ -21,6 +21,7 @@ import ActionButton from "../../react/ActionButton";
import { RefObject } from "preact";
import TouchBar, { TouchBarButton, TouchBarLabel, TouchBarSegmentedControl, TouchBarSpacer } from "../../react/TouchBar";
import { openCalendarContextMenu } from "./context_menu";
+import { isMobile } from "../../../services/utils";
interface CalendarViewData {
@@ -266,7 +267,7 @@ function useEventDisplayCustomization(parentNote: FNote) {
// Prepend the icon to the title, if any.
if (iconClass) {
- let titleContainer;
+ let titleContainer: HTMLElement | null = null;
switch (e.view.type) {
case "timeGridWeek":
case "dayGridMonth":
@@ -285,6 +286,9 @@ function useEventDisplayCustomization(parentNote: FNote) {
}
}
+ // Disable the default context menu.
+ e.el.dataset.noContextMenu = "true";
+
// Append promoted attributes to the end of the event container.
if (promotedAttributes) {
let promotedAttributesHtml = "";
@@ -310,12 +314,18 @@ function useEventDisplayCustomization(parentNote: FNote) {
$(mainContainer ?? e.el).append($(promotedAttributesHtml));
}
- e.el.addEventListener("contextmenu", async (contextMenuEvent) => {
+ async function onContextMenu(contextMenuEvent: PointerEvent) {
const note = await froca.getNote(e.event.extendedProps.noteId);
if (!note) return;
openCalendarContextMenu(contextMenuEvent, note, parentNote);
- });
+ }
+
+ if (isMobile()) {
+ e.el.addEventListener("click", onContextMenu);
+ } else {
+ e.el.addEventListener("contextmenu", onContextMenu);
+ }
}, []);
return { eventDidMount };
}