From 1d1639e5e147dd5b80e286357ac8c0c6dd785d62 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 29 Nov 2025 21:27:27 +0200 Subject: [PATCH] feat(mobile/split): limit to maximum two splits per tab --- .../src/widgets/containers/split_note_container.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.ts index d50fcab1e..fbb7fd31f 100644 --- a/apps/client/src/widgets/containers/split_note_container.ts +++ b/apps/client/src/widgets/containers/split_note_container.ts @@ -4,6 +4,7 @@ import type BasicWidget from "../basic_widget.js"; import Component from "../../components/component.js"; import splitService from "../../services/resizer.js"; import { isMobile } from "../../services/utils.js"; +import NoteContext from "../../components/note_context.js"; interface SplitNoteWidget extends BasicWidget { hasBeenAlreadyShown?: boolean; @@ -56,7 +57,8 @@ export default class SplitNoteContainer extends FlexContainer { } async openNewNoteSplitEvent({ ntxId, notePath, hoistedNoteId, viewScope }: EventData<"openNewNoteSplit">) { - const mainNtxId = appContext.tabManager.getActiveMainContext()?.ntxId; + const activeContext = appContext.tabManager.getActiveMainContext(); + const mainNtxId = activeContext?.ntxId; if (!mainNtxId) { console.warn("Missing main note context ID"); return; @@ -70,7 +72,14 @@ export default class SplitNoteContainer extends FlexContainer { hoistedNoteId = hoistedNoteId || appContext.tabManager.getActiveContext()?.hoistedNoteId; - const noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId, mainNtxId); + + const subContexts = activeContext.getSubContexts(); + let noteContext: NoteContext; + if (isMobile() && subContexts.length > 1) { + noteContext = subContexts.find(s => s.ntxId !== ntxId)!; + } else { + noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId, mainNtxId); + } if (!noteContext.ntxId) { logError("Failed to create new note context!"); return;