A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix note already opened in another tab is not focused
Abdullah Atta1a1b4bc43ca6
diff --git a/apps/web/__e2e__/models/tab-item.model.ts b/apps/web/__e2e__/models/tab-item.model.tsindex f18db1b8e..66f3c4164 100644--- a/apps/web/__e2e__/models/tab-item.model.ts+++ b/apps/web/__e2e__/models/tab-item.model.ts@@ -39,6 +39,11 @@ export class TabItemModel {return this.locator.locator(getTestId("tab-title")).textContent();}+ async isActive() {+ const classList = await this.locator.getAttribute("class");+ return !!classList?.includes("active");+ }+close() {return this.closeButton.click();}diff --git a/apps/web/__e2e__/tabs.test.ts b/apps/web/__e2e__/tabs.test.tsindex 3d242cd00..e63d0fd74 100644--- a/apps/web/__e2e__/tabs.test.ts+++ b/apps/web/__e2e__/tabs.test.ts@@ -209,5 +209,26 @@ test("navigate back and forth between normal and diff session", async ({);});+test("clicking on a note that's already opened in another tab should focus the tab", 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 note?.openNote();++ const tabs = await notes.editor.getTabs();+ expect(await tabs[0].isActive()).toBe(true);+});+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.tsxindex 73d108d38..f95be9a4d 100644--- a/apps/web/src/components/editor/action-bar.tsx+++ b/apps/web/src/components/editor/action-bar.tsx@@ -493,7 +493,7 @@ function Tab(props: TabProps) {setNodeRef(el);activeTabRef.current = el;}}- className="tab"+ className={`tab${isActive || active?.id === id ? " active" : ""}`}data-test-id={`tab-${id}`}sx={{height: "100%",diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.tsindex 9a4c6ed22..63225f7b9 100644--- a/apps/web/src/stores/editor-store.ts+++ b/apps/web/src/stores/editor-store.ts@@ -572,10 +572,14 @@ class EditorStore extends BaseStore<EditorStore> {});if (session?.tabId) {- const { tabs } = this.get();+ const { tabs, activeTabId } = this.get();const index = tabs.findIndex((t) => t.id === session.tabId);// no need to focus tab if the same session is already open- if (index === -1 || tabs[index].sessionId === session.id) return;+ if (+ index === -1 ||+ (activeTabId === session.tabId && tabs[index].sessionId === session.id)+ )+ return;this.set((state) => (state.tabs[index].sessionId = session.id));if (!silent) this.focusTab(session.tabId, session.id);}