Skip to content

Build your personal knowledge base with Trilium Notes

fix(mobile/split): swapping between splits

Elian Doran99da145d65cc
diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.ts
index fbb7fd31f1..d5a2b39e9a 100644
--- a/apps/client/src/widgets/containers/split_note_container.ts
+++ b/apps/client/src/widgets/containers/split_note_container.ts
@@ -79,22 +79,22 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
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;
- }
+ // 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[];
- // 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[];
+ // insert the note context after the originating note context
+ if (!noteContext.ntxId) {
+ logError("Failed to create new note context!");
+ return;
+ }
+ ntxIds.splice(ntxIds.indexOf(ntxId) + 1, 0, noteContext.ntxId);
- // insert the note context after the originating note context
- ntxIds.splice(ntxIds.indexOf(ntxId) + 1, 0, noteContext.ntxId);
+ this.triggerCommand("noteContextReorder", { ntxIdsInOrder: ntxIds });
- this.triggerCommand("noteContextReorder", { ntxIdsInOrder: ntxIds });
+ // move the note context rendered widget after the originating widget
+ this.$widget.find(`[data-ntx-id="${noteContext.ntxId}"]`).insertAfter(this.$widget.find(`[data-ntx-id="${ntxId}"]`));
+ }
- // move the note context rendered widget after the originating widget
- this.$widget.find(`[data-ntx-id="${noteContext.ntxId}"]`).insertAfter(this.$widget.find(`[data-ntx-id="${ntxId}"]`));
await appContext.tabManager.activateNoteContext(noteContext.ntxId);