diff --git a/e2e/layout/tab_bar.spec.ts b/e2e/layout/tab_bar.spec.ts index ccaff3876..fe5a06a54 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.ts index a4d00a075..937bd8982 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 it return false; }