web: ignore notes in other tabs when navigating back

This commit is contained in:
Abdullah Atta
2025-02-01 14:26:01 +05:00
parent 821b8eebaa
commit 62da8484ad
3 changed files with 24 additions and 2 deletions

View File

@@ -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", () => {});

View File

@@ -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)}

View File

@@ -655,7 +655,7 @@ class EditorStore extends BaseStore<EditorStore> {
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());