Skip to content

Build your personal knowledge base with Trilium Notes

fix(tab_manager): correct order when reopening tabs

SiriusXT4afea27fa526
diff --git a/apps/client/src/widgets/tab_row.ts b/apps/client/src/widgets/tab_row.ts
index c2405aaed7..b78952fafb 100644
--- a/apps/client/src/widgets/tab_row.ts
+++ b/apps/client/src/widgets/tab_row.ts
@@ -820,12 +820,15 @@ export default class TabRowWidget extends BasicWidget {
}
contextsReopenedEvent({ mainNtxId, tabPosition }: EventData<"contextsReopened">) {
- if (!mainNtxId || !tabPosition) {
+ if (!mainNtxId || tabPosition < 0) {
// no tab reopened
return;
}
const tabEl = this.getTabById(mainNtxId)[0];
- tabEl.parentNode?.insertBefore(tabEl, this.tabEls[tabPosition]);
+
+ if ( tabEl && tabEl.parentNode ){
+ tabEl.parentNode.insertBefore(tabEl, this.tabEls[tabPosition]);
+ }
}
updateTabById(ntxId: string | null) {