Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(tab_bar): empty tabs not properly removed at app start
Elian Dorana8319fcbdf6a
diff --git a/e2e/layout/tab_bar.spec.ts b/e2e/layout/tab_bar.spec.tsindex ccaff38769..fe5a06a54b 100644--- a/e2e/layout/tab_bar.spec.ts+++ b/e2e/layout/tab_bar.spec.ts@@ -82,3 +82,21 @@ test("Tabs are restored in right order", async ({ page, context }) => {// Check the note tree has the right active node.await expect(app.noteTreeActiveNote).toContainText("Text notes");});++test("Empty tabs are cleared out", async ({ page, context }) => {+ const app = new App(page, context);+ await app.goto();++ // Open three tabs.+ await app.closeAllTabs();+ await app.addNewTab();+ await app.goToNoteInNewTab("Code notes");+ await app.addNewTab();+ await app.addNewTab();++ // Refresh the page and check the order.+ await app.goto({ preserveTabs: true });++ // Expect no empty tabs.+ expect(await app.tabBar.locator(".note-tab-wrapper").count()).toBe(1);+});diff --git a/src/public/app/components/tab_manager.ts b/src/public/app/components/tab_manager.tsindex a4d00a075c..937bd89821 100644--- a/src/public/app/components/tab_manager.ts+++ b/src/public/app/components/tab_manager.ts@@ -75,7 +75,7 @@ export default class TabManager extends Component {const filteredNoteContexts = noteContextsToOpen.filter((openTab: NoteContextState) => {const noteId = treeService.getNoteIdFromUrl(openTab.notePath);- if (noteId && !(noteId in froca.notes)) {+ if (!noteId || !(noteId in froca.notes)) {// note doesn't exist so don't try to open tab for itreturn false;}