AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(web): stabilize notebook icon selection in Safari (#746)
Thorsten Ruf512772538f27
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex ca8c6cea..06724f7e 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -1,6 +1,6 @@name: Test-# Runs the non-E2E regression suite, lint, type checks and the web build for every+# Runs regression tests, focused browser tests, lint, type checks and the web build for every# pull request and every push to main, so failures surface before a release# instead of in the release workflow.on:@@ -94,3 +94,36 @@ jobs:- name: Run regression testsrun: bun run test++ notebook-appearance:+ if: github.repository == 'tianma-if/edgeever'+ name: Notebook appearance (Chromium and WebKit)+ # Safari's mouse-focus behavior differs from Chromium and from Linux WebKit.+ runs-on: macos-latest+ timeout-minutes: 20+ steps:+ - name: Checkout+ uses: actions/checkout@v5++ - name: Set up Bun+ uses: oven-sh/setup-bun@v2+ with:+ bun-version-file: package.json++ - name: Install dependencies+ run: |+ for attempt in 1 2 3; do+ if bun install --frozen-lockfile; then+ exit 0+ fi+ if [[ "$attempt" = "3" ]]; then+ exit 1+ fi+ sleep "$((15 * attempt))"+ done++ - name: Install Chromium and WebKit+ run: bun run test:e2e:install++ - name: Test notebook appearance in both browsers+ run: bun run test:e2e tests/e2e/notebook-appearance.spec.tsdiff --git a/apps/web/src/components/dialogs/NotebookAppearanceDialog.tsx b/apps/web/src/components/dialogs/NotebookAppearanceDialog.tsxindex d8604798..806d251a 100644--- a/apps/web/src/components/dialogs/NotebookAppearanceDialog.tsx+++ b/apps/web/src/components/dialogs/NotebookAppearanceDialog.tsx@@ -1,4 +1,4 @@-import { useId, useState, type FormEvent } from "react";+import { useId, useRef, useState, type FormEvent } from "react";import { useTranslation } from "react-i18next";import {Bold,@@ -60,6 +60,7 @@ export const NotebookAppearanceDialog = ({const [visibleIconCount, setVisibleIconCount] = useState(40);const [iconQuery, setIconQuery] = useState("");const [iconOpen, setIconOpen] = useState(false);+ const iconTriggerRef = useRef<HTMLButtonElement>(null);const [saving, setSaving] = useState(false);const [failed, setFailed] = useState(false);const validColor = color === "" || isNotebookColor(color);@@ -103,6 +104,7 @@ export const NotebookAppearanceDialog = ({if (iconOpen) {event.preventDefault();setIconOpen(false);+ iconTriggerRef.current?.focus();}}}>@@ -142,11 +144,12 @@ export const NotebookAppearanceDialog = ({event.preventDefault();event.stopPropagation();setIconOpen(false);- event.currentTarget.querySelector("button")?.focus();+ iconTriggerRef.current?.focus();}}}><button+ ref={iconTriggerRef}type="button"aria-label={t("notebookAppearance.icon")}aria-expanded={iconOpen}@@ -176,6 +179,10 @@ export const NotebookAppearanceDialog = ({<InputautoFocusvalue={iconQuery}+ onKeyDown={(event) => {+ // Searching must not submit the appearance form.+ if (event.key === "Enter") event.preventDefault();+ }}onChange={(event) => {setIconQuery(event.target.value);setVisibleIconCount(40);@@ -209,6 +216,9 @@ export const NotebookAppearanceDialog = ({type="button"role="option"aria-selected={icon === item.id}+ // Safari does not focus clicked buttons; keep the search+ // focused until the option's click handler has run.+ onMouseDown={(event) => event.preventDefault()}onClick={() => {setIcon(item.id);setIconOpen(false);diff --git a/package.json b/package.jsonindex 9efde536..4bb6a0b4 100644--- a/package.json+++ b/package.json@@ -52,7 +52,7 @@"package:extension:firefox": "bun run --cwd apps/extension package:firefox","test:extension": "bun run --cwd apps/extension test","test:e2e": "playwright test",- "test:e2e:install": "playwright install chromium",+ "test:e2e:install": "playwright install chromium webkit","dev:extension": "vite --config apps/extension/vite.config.ts","prepare:poster:thumbnails": "bun scripts/prepare-poster-thumbnails.mjs","check:poster:thumbnails": "bun scripts/prepare-poster-thumbnails.mjs --check",diff --git a/playwright.config.ts b/playwright.config.tsindex e385e525..a92c2544 100644--- a/playwright.config.ts+++ b/playwright.config.ts@@ -22,6 +22,12 @@ export default defineConfig({name: "chromium",use: { ...devices["Desktop Chrome"] },},+ {+ name: "webkit",+ // Keep Safari coverage focused on the appearance interactions for now.+ testMatch: "notebook-appearance.spec.ts",+ use: { ...devices["Desktop Safari"] },+ },],webServer: {command: "bun run dev",diff --git a/tests/e2e/notebook-appearance.spec.ts b/tests/e2e/notebook-appearance.spec.tsindex d70d20ff..48b854a3 100644--- a/tests/e2e/notebook-appearance.spec.ts+++ b/tests/e2e/notebook-appearance.spec.ts@@ -1,4 +1,97 @@-import { expect, test } from "@playwright/test";+import { expect, test, type Page } from "@playwright/test";++const createAppearanceNotebook = async (page: Page) => {+ await page.addInitScript(() => localStorage.setItem("edgeever.locale.preference", "en-US"));+ await page.goto("/");+ const name = `Appearance interaction ${Date.now()}`;+ const created = await page.request.post("/api/v1/notebooks", { data: { name } });+ expect(created.ok()).toBeTruthy();+ const { notebook } = await created.json();+ const row = page.locator(`[data-notebook-id="${notebook.id}"]`);+ const dialog = page.getByRole("dialog", { name: "Appearance", exact: true });+ return {+ row,+ dialog,+ read: async () => {+ const response = await page.request.get("/api/v1/notebooks");+ expect(response.ok()).toBeTruthy();+ return (await response.json()).notebooks.find((item: { id: string }) => item.id === notebook.id);+ },+ open: async () => {+ await page.reload();+ await expect(row).toBeVisible();+ await row.hover();+ await row.getByRole("button", { name: `Open actions for ${name}`, exact: true }).click();+ await page.getByRole("button", { name: "Appearance", exact: true }).click();+ await expect(dialog).toBeVisible();+ },+ remove: async () => {+ const response = await page.request.delete(`/api/v1/notebooks/${notebook.id}`);+ expect(response.ok()).toBeTruthy();+ },+ };+};++test("selects a notebook icon with the mouse after searching and persists it across reloads", async ({ page }) => {+ const { row, dialog, read, open, remove } = await createAppearanceNotebook(page);+ try {+ await open();+ await dialog.getByRole("button", { name: "Icon", exact: true }).click();+ const search = dialog.getByPlaceholder("Search icons (English or German)");+ await search.fill("alarm-clock");+ await expect(search).toBeFocused();+ // Use a real mouse click: dispatchEvent("click") skips Safari's blur-before-click sequence.+ await dialog.getByRole("option", { name: "alarm clock", exact: true }).click();+ await expect(dialog.getByRole("listbox")).toBeHidden();+ await expect(dialog.locator("[data-notebook-appearance-preview] [data-notebook-icon]")).toHaveAttribute("data-notebook-icon", "alarm-clock");+ expect(await read()).toMatchObject({ icon: null });+ await dialog.getByRole("button", { name: "Confirm", exact: true }).click();+ await expect(dialog).toBeHidden();+ await expect.poll(read).toMatchObject({ icon: "alarm-clock" });+ await page.reload();+ await expect(row.locator("[data-notebook-icon]")).toHaveAttribute("data-notebook-icon", "alarm-clock");+ await expect(row.locator('[data-notebook-icon] circle[cx="12"][cy="13"]')).toHaveCount(1);+ } finally {+ await remove();+ }+});++test("keeps icon searches as drafts on Enter and supports keyboard selection and cancellation", async ({ page }) => {+ const { dialog, read, open, remove } = await createAppearanceNotebook(page);+ try {+ await open();+ await dialog.getByRole("switch", { name: "Bold", exact: true }).check();+ await dialog.getByRole("button", { name: "Icon", exact: true }).click();+ const search = dialog.getByPlaceholder("Search icons (English or German)");+ await search.fill("house");+ await search.press("Enter");+ await expect(dialog).toBeVisible();+ await expect(search).toBeFocused();+ await expect(dialog.getByRole("listbox")).toBeVisible();+ expect(await read()).toMatchObject({ icon: null, isBold: false });+ await search.press("Escape");+ await expect(dialog.getByRole("listbox")).toBeHidden();+ await expect(dialog).toBeVisible();+ await expect(dialog.getByRole("button", { name: "Icon", exact: true })).toBeFocused();+ await dialog.getByRole("button", { name: "Icon", exact: true }).press("Enter");+ await search.fill("house");+ const option = dialog.getByRole("option", { name: "house", exact: true });+ await option.focus();+ await option.press("Enter");+ await expect(dialog.getByRole("listbox")).toBeHidden();+ await expect(dialog.locator("[data-notebook-appearance-preview] [data-notebook-icon]")).toHaveAttribute("data-notebook-icon", "house");+ await dialog.getByRole("button", { name: "Cancel", exact: true }).click();+ await expect(dialog).toBeHidden();+ expect(await read()).toMatchObject({ icon: null, isBold: false });+ await open();+ await expect(dialog.getByRole("switch", { name: "Bold", exact: true })).not.toBeChecked();+ await expect(dialog.locator("[data-notebook-appearance-preview] [data-notebook-icon]")).toHaveAttribute("data-notebook-icon", "notebook");+ await page.keyboard.press("Escape");+ await expect(dialog).toBeHidden();+ } finally {+ await remove();+ }+});test("saves notebook appearance, keeps drafts on cancel, and resets across reloads and themes", async ({ page }) => {await page.addInitScript(() => {@@ -23,7 +116,7 @@ test("saves notebook appearance, keeps drafts on cancel, and resets across reloaawait expect(dialog).toBeVisible();};const save = async () => {- await dialog.getByRole("button", { name: "Save", exact: true }).click();+ await dialog.getByRole("button", { name: "Confirm", exact: true }).click();await expect(dialog).toBeHidden();};try {