From 2cf6fe435247f1a4d6effa2a9bfde064701d56cc Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 29 Nov 2025 21:11:16 +0200 Subject: [PATCH] feat(mobile/split): option to close split --- .../mobile_widgets/mobile_detail_menu.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx index 79ac24aac..8859f7b3d 100644 --- a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx +++ b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx @@ -1,6 +1,6 @@ import { useContext } from "preact/hooks"; import appContext, { CommandMappings } from "../../components/app_context"; -import contextMenu from "../../menus/context_menu"; +import contextMenu, { MenuItem } from "../../menus/context_menu"; import branches from "../../services/branches"; import { t } from "../../services/i18n"; import note_create from "../../services/note_create"; @@ -18,18 +18,22 @@ export default function MobileDetailMenu() { text="" onClick={(e) => { const note = appContext.tabManager.getActiveContextNote(); + const noteContext = appContext.tabManager.getActiveContext(); + + const items: (MenuItem | false)[] = [ + { title: t("mobile_detail_menu.insert_child_note"), command: "insertChildNote", uiIcon: "bx bx-plus", enabled: note?.type !== "search" }, + { title: t("mobile_detail_menu.delete_this_note"), command: "delete", uiIcon: "bx bx-trash", enabled: note?.noteId !== "root" }, + { kind: "separator" }, + { title: t("mobile_detail_menu.note_revisions"), command: "showRevisions", uiIcon: "bx bx-history" }, + { kind: "separator" }, + { title: t("create_pane_button.create_new_split"), command: "openNewNoteSplit", uiIcon: "bx bx-dock-right" }, + !noteContext?.isMainContext() && { title: t("close_pane_button.close_this_pane"), command: "closeThisNoteSplit", uiIcon: "bx bx-x" } + ]; contextMenu.show({ x: e.pageX, y: e.pageY, - items: [ - { title: t("mobile_detail_menu.insert_child_note"), command: "insertChildNote", uiIcon: "bx bx-plus", enabled: note?.type !== "search" }, - { title: t("mobile_detail_menu.delete_this_note"), command: "delete", uiIcon: "bx bx-trash", enabled: note?.noteId !== "root" }, - { kind: "separator" }, - { title: t("mobile_detail_menu.note_revisions"), command: "showRevisions", uiIcon: "bx bx-history" }, - { kind: "separator" }, - { title: t("create_pane_button.create_new_split"), command: "openNewNoteSplit", uiIcon: "bx bx-dock-right" }, - ], + items: items.filter(i => !!i), selectMenuItemHandler: async ({ command }) => { if (command === "insertChildNote") { note_create.createNote(appContext.tabManager.getActiveContextNotePath() ?? undefined);