chore(mobile/split): address requested changes
Some checks failed
Checks / main (push) Has been cancelled

This commit is contained in:
Elian Doran 2025-12-01 23:51:12 +02:00
parent e0e9310907
commit 28b263a445
No known key found for this signature in database
3 changed files with 9 additions and 6 deletions

View File

@ -49,8 +49,10 @@ function getNtxId(e: ContextMenuEvent) {
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts(); const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
if (!subContexts) return null; if (!subContexts) return null;
return subContexts[subContexts.length - 1].ntxId; return subContexts[subContexts.length - 1].ntxId;
} else { } else if (e.target instanceof HTMLElement) {
return getClosestNtxId(e.target); return getClosestNtxId(e.target);
} else {
return null;
} }
} }

View File

@ -74,13 +74,14 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
const subContexts = activeContext.getSubContexts(); const subContexts = activeContext.getSubContexts();
let noteContext: NoteContext; let noteContext: NoteContext | undefined = undefined;
if (isMobile() && subContexts.length > 1) { if (isMobile() && subContexts.length > 1) {
noteContext = subContexts.find(s => s.ntxId !== ntxId)!; noteContext = subContexts.find(s => s.ntxId !== ntxId);
} else { }
if (!noteContext) {
noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId, mainNtxId); noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId, mainNtxId);
// remove the original position of newly created note context // remove the original position of newly created note context
const ntxIds = appContext.tabManager.children.map((c) => c.ntxId).filter((id) => id !== noteContext.ntxId) as string[]; const ntxIds = appContext.tabManager.children.map((c) => c.ntxId).filter((id) => id !== noteContext?.ntxId) as string[];
// insert the note context after the originating note context // insert the note context after the originating note context
if (!noteContext.ntxId) { if (!noteContext.ntxId) {

View File

@ -17,7 +17,7 @@ export default function MobileDetailMenu() {
icon="bx bx-dots-vertical-rounded" icon="bx bx-dots-vertical-rounded"
text="" text=""
onClick={(e) => { onClick={(e) => {
const ntxId = (parentComponent as BasicWidget).getClosestNtxId(); const ntxId = (parentComponent as BasicWidget | null)?.getClosestNtxId();
if (!ntxId) return; if (!ntxId) return;
const noteContext = appContext.tabManager.getNoteContextById(ntxId); const noteContext = appContext.tabManager.getNoteContextById(ntxId);