Skip to content

Commit 13afe33

Browse files
committed
fix(tab_manager): correct order when reopening split pane
1 parent f57e90b commit 13afe33

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/client/src/widgets/containers/split_note_container.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
181181
splitService.delNoteSplitResizer(ntxIds);
182182
}
183183

184-
contextsReopenedEvent({ ntxId, mainNtxId, tabPosition, afterNtxId }: EventData<"contextsReopened">) {
184+
contextsReopenedEvent({ ntxId, mainNtxId, afterNtxId }: EventData<"contextsReopened">) {
185185
if (ntxId !== undefined && afterNtxId !== undefined) {
186186
this.$widget.find(`[data-ntx-id="${ntxId}"]`).insertAfter(this.$widget.find(`[data-ntx-id="${afterNtxId}"]`));
187-
} else if (mainNtxId && tabPosition >= 0) {
187+
} else if (mainNtxId) {
188188
const contexts = appContext.tabManager.noteContexts;
189-
const beforeNtxId = contexts.find(c => c.mainNtxId === mainNtxId)?.ntxId || null;
189+
const nextIndex = contexts.findIndex(c => c.ntxId === mainNtxId);
190+
const beforeNtxId = (nextIndex !== -1 && nextIndex + 1 < contexts.length) ? contexts[nextIndex + 1].ntxId : null;
191+
190192
this.$widget.find(`[data-ntx-id="${mainNtxId}"]`).insertBefore(this.$widget.find(`[data-ntx-id="${beforeNtxId}"]`));
191193
}
192194
}

0 commit comments

Comments
 (0)