diff --git a/apps/web/__e2e__/tabs.test.ts b/apps/web/__e2e__/tabs.test.ts index e63d0fd74..9fa55517d 100644 --- a/apps/web/__e2e__/tabs.test.ts +++ b/apps/web/__e2e__/tabs.test.ts @@ -230,5 +230,27 @@ test("clicking on a note that's already opened in another tab should focus the t expect(await tabs[0].isActive()).toBe(true); }); +test("open a note in 2 tabs then open another note and navigate back", async ({ + page +}) => { + const app = new AppModel(page); + await app.goto(); + const notes = await app.goToNotes(); + const note = await notes.createNote({ + title: "Note 1" + }); + await note?.contextMenu.openInNewTab(); + await notes.editor.waitForLoading(); + await notes.createNote({ + title: "Note 2" + }); + + await notes.editor.goBack(); + + const tabs = await notes.editor.getTabs(); + expect(await tabs[1].isActive()).toBe(true); + expect(await tabs[1].title()).toBe("Note 1"); +}); + test.skip("TODO: open a locked note, switch to another note and navigate back", () => {}); test.skip("TODO: open a locked note, switch to another note, unlock the note and navigate back", () => {}); diff --git a/apps/web/src/components/editor/action-bar.tsx b/apps/web/src/components/editor/action-bar.tsx index f95be9a4d..b6d38accd 100644 --- a/apps/web/src/components/editor/action-bar.tsx +++ b/apps/web/src/components/editor/action-bar.tsx @@ -359,7 +359,7 @@ function TabStrip() { type={session.type} onFocus={() => { if (tab.id !== currentTab) { - useEditorStore.getState().focusTab(tab.id); + useEditorStore.getState().activateSession(tab.sessionId); } }} onClose={() => useEditorStore.getState().closeTabs(tab.id)} diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts index ec15f30a6..ad38d969e 100644 --- a/apps/web/src/stores/editor-store.ts +++ b/apps/web/src/stores/editor-store.ts @@ -655,7 +655,7 @@ class EditorStore extends BaseStore { addTab } = this.get(); const noteId = typeof noteOrId === "string" ? noteOrId : noteOrId.id; - const oldTabForNote = getTabsForNote(noteId).at(0); + const oldTabForNote = options.force ? null : getTabsForNote(noteId).at(0); const tabId = options.openInNewTab ? addTab(getId()) : oldTabForNote?.id || activeTabId || addTab(getId());