Skip to content

Build your personal knowledge base with Trilium Notes

chore(mobile/split): address requested changes

Elian Doran28b263a44537
diff --git a/apps/client/src/menus/link_context_menu.ts b/apps/client/src/menus/link_context_menu.ts
index a8de838837..6683bc27a0 100644
--- a/apps/client/src/menus/link_context_menu.ts
+++ b/apps/client/src/menus/link_context_menu.ts
@@ -49,8 +49,10 @@ function getNtxId(e: ContextMenuEvent) {
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
if (!subContexts) return null;
return subContexts[subContexts.length - 1].ntxId;
- } else {
+ } else if (e.target instanceof HTMLElement) {
return getClosestNtxId(e.target);
+ } else {
+ return null;
}
}
diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.ts
index d5a2b39e9a..1cee46b73b 100644
--- a/apps/client/src/widgets/containers/split_note_container.ts
+++ b/apps/client/src/widgets/containers/split_note_container.ts
@@ -74,13 +74,14 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
const subContexts = activeContext.getSubContexts();
- let noteContext: NoteContext;
+ let noteContext: NoteContext | undefined = undefined;
if (isMobile() && subContexts.length > 1) {
- noteContext = subContexts.find(s => s.ntxId !== ntxId)!;
- } else {
+ noteContext = subContexts.find(s => s.ntxId !== ntxId);
+ }
+ if (!noteContext) {
noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId, mainNtxId);
// 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
if (!noteContext.ntxId) {
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 0c6c3dfff3..765bb4c31e 100644
--- a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx
+++ b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx
@@ -17,7 +17,7 @@ export default function MobileDetailMenu() {
icon="bx bx-dots-vertical-rounded"
text=""
onClick={(e) => {
- const ntxId = (parentComponent as BasicWidget).getClosestNtxId();
+ const ntxId = (parentComponent as BasicWidget | null)?.getClosestNtxId();
if (!ntxId) return;
const noteContext = appContext.tabManager.getNoteContextById(ntxId);