From f039bc000095e4ef07f87c1a121c34c1c4de47b7 Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 4 Dec 2026 17:46:19 +0000 Subject: [PATCH 1/5] fix(web): make summary toggle keyboard accessible --- web/src/modules/article/components/EditorMetaPanel.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/modules/article/components/EditorMetaPanel.tsx b/web/src/modules/article/components/EditorMetaPanel.tsx index 2c68f522..a0641ab4 100644 --- a/web/src/modules/article/components/EditorMetaPanel.tsx +++ b/web/src/modules/article/components/EditorMetaPanel.tsx @@ -14,12 +14,17 @@ export function EditorMetaPanel({ title, defaultOpen = true, children }: EditorM return (
-
setOpen((v) => !v)}> +
+ {open ?
{children}
: null}
); From 9c288f8b0ba6a0e30dd10992a50dfc4a6a65a1ad Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 4 Dec 2026 17:46:40 +0000 Subject: [PATCH 2/5] style(web): preserve summary toggle layout and focus --- .../article/components/editor-meta-panel.module.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/src/modules/article/components/editor-meta-panel.module.css b/web/src/modules/article/components/editor-meta-panel.module.css index b3092a17..ae43d6b9 100644 --- a/web/src/modules/article/components/editor-meta-panel.module.css +++ b/web/src/modules/article/components/editor-meta-panel.module.css @@ -12,13 +12,22 @@ display: flex; align-items: center; justify-content: space-between; + width: 100%; padding: 10px 12px; background: var(--editor-surface-muted); + border: 0; border-bottom: 1px solid var(--editor-border-secondary); + font: inherit; + text-align: start; cursor: pointer; user-select: none; } +.header:focus-visible { + outline: 2px solid var(--editor-accent); + outline-offset: -2px; +} + .title { font-size: 13px; font-weight: 600; From 356e9002e825a2448017fafcd3cc61d67041f479 Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 4 Dec 2026 17:47:01 +0000 Subject: [PATCH 3/5] fix(web): make editor toolbar keyboard operable --- web/src/shared/components/Editor/index.tsx | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/web/src/shared/components/Editor/index.tsx b/web/src/shared/components/Editor/index.tsx index 90e34f4c..d24c4e7d 100644 --- a/web/src/shared/components/Editor/index.tsx +++ b/web/src/shared/components/Editor/index.tsx @@ -223,7 +223,9 @@ export function MarkdownEditor({
- {t("editor.modeEdit")} - - + - toggleTocVisible()}> + - void toggleFullscreen()} > @@ -275,7 +288,7 @@ export function MarkdownEditor({ ) : ( )} - +
From d6ff0b3f01d36afe1a9e2618f22503dd9de48c26 Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 4 Dec 2026 17:47:19 +0000 Subject: [PATCH 4/5] style(web): retain toolbar layout and mark keyboard focus --- web/src/shared/components/Editor/editor.module.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/src/shared/components/Editor/editor.module.css b/web/src/shared/components/Editor/editor.module.css index 6593a906..aca53471 100644 --- a/web/src/shared/components/Editor/editor.module.css +++ b/web/src/shared/components/Editor/editor.module.css @@ -85,6 +85,9 @@ .toolbarAction { padding: 0 10px; + border: 0; + background: transparent; + font-family: inherit; font-size: 12px; line-height: 28px; white-space: nowrap; @@ -98,6 +101,11 @@ background: var(--editor-hover-bg); } +.toolbarAction:focus-visible { + outline: 2px solid var(--editor-accent); + outline-offset: -2px; +} + .toolbarActionActive { background: var(--editor-active-bg); font-weight: 600; From d139688de9eb06a75f90e5ef7b0aa6478d7f52ce Mon Sep 17 00:00:00 2001 From: Devashish Date: Fri, 4 Dec 2026 17:48:13 +0000 Subject: [PATCH 5/5] test(web): cover article editor keyboard controls --- web/e2e/article-editor.spec.ts | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 web/e2e/article-editor.spec.ts diff --git a/web/e2e/article-editor.spec.ts b/web/e2e/article-editor.spec.ts new file mode 100644 index 00000000..861cecaa --- /dev/null +++ b/web/e2e/article-editor.spec.ts @@ -0,0 +1,50 @@ +import { expect, test } from "@playwright/test"; + +import { loginAsAdmin } from "./helpers"; + +test.beforeEach(async ({ page }) => { + await loginAsAdmin(page); + await page.goto("/article/editor"); +}); + +test("toggles the article summary with Enter and Space", async ({ page }) => { + const summary = page.getByRole("button", { name: /^(Summary|文章摘要)$/ }); + const content = page.getByPlaceholder(/Enter article summary|请输入文章摘要/); + + await expect(summary).toHaveAttribute("aria-expanded", "true"); + await summary.press("Enter"); + await expect(summary).toHaveAttribute("aria-expanded", "false"); + await expect(summary).toBeFocused(); + await expect(content).toBeHidden(); + + await summary.press("Space"); + await expect(summary).toHaveAttribute("aria-expanded", "true"); + await expect(content).toBeVisible(); +}); + +test("moves between editor toolbar buttons and activates them with the keyboard", async ({ + page, +}) => { + const split = page.getByRole("button", { name: /^(Split|分屏)$/ }); + const toolbar = page.locator("header").filter({ has: split }); + const edit = toolbar.getByRole("button", { name: /^(Edit|编辑)$/ }); + const preview = toolbar.getByRole("button", { name: /^(Preview|预览)$/ }); + const outline = toolbar.getByRole("button", { name: /^(Outline|大纲)$/ }); + + await expect(split).toHaveAttribute("aria-pressed", "true"); + await edit.press("Enter"); + await expect(edit).toHaveAttribute("aria-pressed", "true"); + await page.keyboard.press("Tab"); + await expect(split).toBeFocused(); + await page.keyboard.press("Tab"); + await expect(preview).toBeFocused(); + await page.keyboard.press("Space"); + await expect(preview).toHaveAttribute("aria-pressed", "true"); + + await outline.press("Enter"); + await expect(outline).toHaveAttribute("aria-pressed", "false"); + await outline.press("Space"); + await expect(outline).toHaveAttribute("aria-pressed", "true"); + await page.keyboard.press("Tab"); + await expect(toolbar.getByRole("button", { name: /^(Fullscreen|全屏)$/ })).toBeFocused(); +});