From 5b1f95f32f280989d7515297cd1b97814f68ccfd Mon Sep 17 00:00:00 2001 From: Hsukqi Lee Date: Sun, 15 Nov 2026 01:55:44 +0800 Subject: [PATCH] fix(web): preserve modal drafts on outside clicks --- .gitattributes | 1 + web/src/components/ImpressionDialog.tsx | 2 +- web/src/pages/Authors.tsx | 1 + web/tests/workspace.spec.ts | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfdb8b7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf diff --git a/web/src/components/ImpressionDialog.tsx b/web/src/components/ImpressionDialog.tsx index b1a9440..7b6051f 100644 --- a/web/src/components/ImpressionDialog.tsx +++ b/web/src/components/ImpressionDialog.tsx @@ -38,7 +38,7 @@ export default function ImpressionDialog({ } } return ( - +
{ diff --git a/web/src/pages/Authors.tsx b/web/src/pages/Authors.tsx index 2296fd5..1d10aa2 100644 --- a/web/src/pages/Authors.tsx +++ b/web/src/pages/Authors.tsx @@ -223,6 +223,7 @@ export default function Authors({ embedded = false }: { embedded?: boolean }) { {content} setOpen(false)} label={profile?.authors.some((a) => a.id === editing?.id) ? '编辑作者' : '新增作者'} > diff --git a/web/tests/workspace.spec.ts b/web/tests/workspace.spec.ts index 6026514..e59f058 100644 --- a/web/tests/workspace.spec.ts +++ b/web/tests/workspace.spec.ts @@ -78,6 +78,11 @@ test('local login, impression, authors, inbox and logout persist across reloads' await dialog .getByLabel('研究印象', { exact: true }) .fill(`LLM prompt injection ${info.project.name}`) + await page.mouse.click(1, 1) + await expect(dialog).toBeVisible() + await expect(dialog.getByLabel('研究印象', { exact: true })).toHaveValue( + `LLM prompt injection ${info.project.name}`, + ) await dialog.getByRole('button', { name: '保存印象' }).click() await expect(dialog).not.toBeVisible() await page.reload() @@ -89,7 +94,16 @@ test('local login, impression, authors, inbox and logout persist across reloads' await visit(page, baseURL, 'authors') await page.getByRole('button', { name: '添加作者', exact: true }).click() const editor = page.getByRole('dialog', { name: '新增作者' }) + await editor.getByRole('button', { name: '取消', exact: true }).click() + await expect(editor).not.toBeVisible() + await page.getByRole('button', { name: '添加作者', exact: true }).click() + await editor.getByRole('button', { name: '关闭编辑', exact: true }).click() + await expect(editor).not.toBeVisible() + await page.getByRole('button', { name: '添加作者', exact: true }).click() await editor.getByLabel('姓名', { exact: true }).fill(`Alice ${info.project.name}`) + await page.mouse.click(1, 1) + await expect(editor).toBeVisible() + await expect(editor.getByLabel('姓名', { exact: true })).toHaveValue(`Alice ${info.project.name}`) await editor.getByLabel('主页链接', { exact: true }).fill('http://127.0.0.1:9') await editor.getByLabel('ML/AI Security', { exact: true }).check() await editor.getByRole('button', { name: '保存作者' }).click()