Skip to content

Build your personal knowledge base with Trilium Notes

fix(client/type_widgets): empty tab not working when closing last tab

Elian Doran763fa0b5158b
diff --git a/apps/client/src/components/tab_manager.ts b/apps/client/src/components/tab_manager.ts
index 03b9d98d6f..517ff2501d 100644
--- a/apps/client/src/components/tab_manager.ts
+++ b/apps/client/src/components/tab_manager.ts
@@ -265,6 +265,7 @@ export default class TabManager extends Component {
mainNtxId: string | null = null
): Promise<NoteContext> {
const noteContext = new NoteContext(ntxId, hoistedNoteId, mainNtxId);
+ noteContext.setEmpty();
const existingNoteContext = this.children.find((nc) => nc.ntxId === noteContext.ntxId);
diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx
index 07035102ea..03b0b64760 100644
--- a/apps/client/src/widgets/NoteDetail.tsx
+++ b/apps/client/src/widgets/NoteDetail.tsx
@@ -278,6 +278,7 @@ async function getCorrespondingWidget(type: ExtendedNoteType): Promise<null | Ty
}
async function getWidgetType(note: FNote | null | undefined, noteContext: NoteContext | undefined): Promise<ExtendedNoteType | undefined> {
+ if (!noteContext) return undefined;
if (!note) {
// If the note is null, then it's a new tab. If it's undefined, then it's not loaded yet.
return note === null ? "empty" : undefined;