From 0aa17da25da474dddbe7afd05004e3fbe895a7d6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 23:12:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20every=20modal=20overlay=20is=20the?= =?UTF-8?q?=20frosted=20veil=20=E2=80=94=20Dialog,=20AlertDialog,=20Sheet,?= =?UTF-8?q?=20Drawer=20and=20admin=20antd=20masks=20(BUG-2276)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The owner (2026-11-23): 「只要是出现弹窗…背景没有磨砂的,需要加上这个」. The four kit overlays used shadcn's bg-black/10, so the page showed through the 星盘类型 dialog and every other modal. They now share .modal-scrim: the annual start veil's canvas at 72% plus a 6px blur, near-solid without backdrop-filter or with reduced transparency. BUG-2252's one-off rule for the report start dialog is folded in; the admin's antd masks get the same veil. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8 --- docs/BUG_HISTORY.md | 18 ++++++ frontend/src/app/admin/admin.css | 21 +++++++ frontend/src/app/annual-report.css | 8 +-- frontend/src/app/globals.css | 22 +++++++ frontend/src/components/ui/alert-dialog.tsx | 2 +- frontend/src/components/ui/dialog.tsx | 2 +- frontend/src/components/ui/drawer.tsx | 2 +- frontend/src/components/ui/sheet.tsx | 2 +- frontend/tests/frosted-overlays-2276.test.ts | 65 ++++++++++++++++++++ 9 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 frontend/tests/frosted-overlays-2276.test.ts diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 44f0a2987..408de4817 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -30670,3 +30670,21 @@ - 未做:自适应扫描本身 20–160 秒偏慢,需要另行优化(缓存预热或缩小首轮扫描);其他网页→排盘调用的上限(星盘 10 秒、出生天空 10 秒、上升预检 3 秒等)生产日志里没有超时记录,这次不改。 - 关联记录:BUG-016(首轮扫描超时打成 503)、BUG-2064(自选范围扫描)。 - 修复版本:分支 `claude/prod-engine-limits-2274`(本地提交,待推送)。 + +## BUG-2276 | 弹窗背后没有磨砂:星盘类型等对话框打开时页面内容透出来,显得乱 + +- 状态:fixed-pending-verify(需在生产 / staging 真机上看一眼星盘类型弹窗) +- 首次发现 / 最近更新:2026-11-23(负责人生产截图:聊天页右侧星盘的「星盘类型」弹窗)/ 2026-11-23 +- 现象:打开「星盘类型」对话框时,背后的聊天正文、盘面和按钮几乎原样透出来,弹窗和页面混在一起。负责人:「只要是出现弹窗的这种情况,如果背景没有磨砂的,需要加上这个,要不然整个页面看起来太乱了」。 +- 触发条件:任何走 `components/ui` 的 Dialog / AlertDialog / Sheet / Drawer(星盘类型、删除确认、退出登录、设置、兑换成功、更新说明、反馈、导出、改出生资料、新增星盘、手机报告提问等),以及后台的 antd Modal / Drawer。 +- 根因:四个弹窗外壳的背景是 shadcn 默认的 `bg-black/10`,只有一层很淡的黑;BUG-2252 只给个人报告开始弹窗单独加了一条磨砂规则,其他弹窗都没有。后台 antd 用默认 45% 黑遮罩。 +- 修复: + - `globals.css` 新增共用 `.modal-scrim`:画布色 72% + 6px 模糊(与年运开始遮罩 `.annual-veil`、BUG-2252 同一观感),浅色深色都随 `--color-canvas`;不支持 backdrop-filter 时退成 92% 几乎实心,`prefers-reduced-transparency` 时 94% 不模糊。 + - `components/ui/dialog.tsx`、`alert-dialog.tsx`、`sheet.tsx`、`drawer.tsx` 的遮罩把 `bg-black/10` 换成 `modal-scrim`,所有弹窗一次生效,不逐个改。 + - 删掉 `annual-report.css` 里 BUG-2252 的单独规则(已被共用类覆盖)。 + - `app/admin/admin.css` 给 antd 的 modal / drawer / 图片预览遮罩同样的磨砂(后台只有浅色,用 `#f3f2ee` 72%)。 + - 不加遮罩的:下拉菜单、选择星盘菜单、常用问题菜单这类非模态弹层;年运开始遮罩本来就是磨砂;出生天空动画是整屏实心。 +- 验证:新增 `frontend/tests/frosted-overlays-2276.test.ts`(5 条:四个外壳都用 `.modal-scrim` 且没有 `bg-black/N`;除 ui 目录外没有直接引用 base-ui dialog / drawer 原件,保证没有绕开外壳的弹窗;`.modal-scrim` 的颜色、模糊与两种降级;没有样式表给外壳遮罩另刷背景;后台 antd 遮罩)。相关弹窗测试 39/39 通过;tsc、eslint、check-built-css 通过。星盘类型弹窗与删除确认,浅色 / 深色、1280 / 390 静态截图看过:背后内容模糊、弹窗清楚。 +- 防复发:弹窗背景只能来自共用 `.modal-scrim`,新增弹窗必须走 `components/ui` 外壳;测试钉住。 +- 关联记录:BUG-2252(个人报告开始弹窗磨砂,已并入)、BUG-2052(年运开始遮罩)、BUG-2259(手机报告提问全屏,不受影响)。 +- 修复版本:分支 `claude/frosted-overlays-2276`(待父会话推送)。 diff --git a/frontend/src/app/admin/admin.css b/frontend/src/app/admin/admin.css index ac240c5ed..2c69557ff 100644 --- a/frontend/src/app/admin/admin.css +++ b/frontend/src/app/admin/admin.css @@ -54,3 +54,24 @@ html, body { /* #330: the small text preview under the success fields of 「新建兑换码」. */ .admin-redeem-preview { display: grid; gap: 2px; justify-items: center; text-align: center; padding: 12px; margin-bottom: 16px; border: 1px dashed #d9d9d9; border-radius: 8px; } + +/* BUG-2276 (产品负责人 2026-11-23): antd modal, drawer and image-preview masks use the same frosted veil as the + product's .modal-scrim (globals.css): the admin canvas #f3f2ee at 72% plus a 6px blur, not antd's plain + 45% black. 原值:antd 默认 colorBgMask;新值:磨砂;原因:弹窗背后的页面看起来太乱。 */ +.ant-modal-root .ant-modal-mask, +.ant-drawer .ant-drawer-mask, +.ant-image-preview-root .ant-image-preview-mask { + background: rgba(243, 242, 238, .72); + -webkit-backdrop-filter: blur(6px); + backdrop-filter: blur(6px); +} +@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { + .ant-modal-root .ant-modal-mask, + .ant-drawer .ant-drawer-mask, + .ant-image-preview-root .ant-image-preview-mask { background: rgba(243, 242, 238, .92); } +} +@media (prefers-reduced-transparency: reduce) { + .ant-modal-root .ant-modal-mask, + .ant-drawer .ant-drawer-mask, + .ant-image-preview-root .ant-image-preview-mask { background: rgba(243, 242, 238, .94); -webkit-backdrop-filter: none; backdrop-filter: none; } +} diff --git a/frontend/src/app/annual-report.css b/frontend/src/app/annual-report.css index 4e7f92335..0ffe828a1 100644 --- a/frontend/src/app/annual-report.css +++ b/frontend/src/app/annual-report.css @@ -422,9 +422,5 @@ .annual-section .report-ask-heading h3 { min-width: 0; } @media print { .annual-page:has(.annual-report[data-ask-open="true"]) { width: auto; } } -/* BUG-2252 (产品负责人 2026-11-23): the personal report's start dialog sits on the same frosted veil as the annual - start overlay (.annual-veil: canvas at 72% and a 6px blur), not on the plain dark scrim. */ -body:has(.report-start-dialog) [data-slot="dialog-overlay"] { - background: color-mix(in srgb, var(--color-canvas) 72%, transparent); - backdrop-filter: blur(6px); -} +/* BUG-2252 (产品负责人 2026-11-23) asked for this veil on the report start dialog; BUG-2276 moved it to the shared + `.modal-scrim` (globals.css) that every dialog, sheet and drawer overlay uses, so no per-dialog rule is needed. */ diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index 676c5ec83..30d8b3246 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -2541,6 +2541,28 @@ button.chat-chart-resize-handle:active { position: absolute; top: 0; left: -3px; [role="tooltip"] { max-width: min(240px, calc(100vw - var(--space-6))); padding: var(--space-2) var(--space-3); border: 1px solid var(--sidebar-border); border-radius: var(--radius-md); background: var(--sidebar-solid); color: var(--sidebar-foreground); box-shadow: var(--shadow-elevated); pointer-events: none; font-size: var(--type-caption); font-weight: 500; line-height: 1.4; transform-origin: var(--transform-origin); transition: opacity 120ms ease-out, transform 120ms var(--ease-out); } [role="tooltip"][data-starting-style], [role="tooltip"][data-ending-style] { opacity: 0; transform: translateX(var(--space-1)); } +/* BUG-2276 (产品负责人 2026-11-23: 「只要是出现弹窗…背景没有磨砂的,需要加上」): one frosted backdrop for + every modal overlay — Dialog, AlertDialog, Sheet and Drawer (components/ui); the admin site's antd masks + get the same veil in app/admin/admin.css. Same veil as the annual start overlay (.annual-veil) and BUG-2252's report start dialog: the + canvas at 72% plus a 6px blur, so the page behind reads as one quiet surface in light and dark. + 原值:bg-black/10(只有一层很淡的黑,页面内容透出来,显得乱);新值:.modal-scrim;原因:同上。 + Without backdrop-filter, or when the reader asks for less transparency, the scrim turns nearly solid. */ +.modal-scrim { + background: color-mix(in srgb, var(--color-canvas) 72%, transparent); + -webkit-backdrop-filter: blur(6px); + backdrop-filter: blur(6px); +} +@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { + .modal-scrim { background: color-mix(in srgb, var(--color-canvas) 92%, transparent); } +} +@media (prefers-reduced-transparency: reduce) { + .modal-scrim { + background: color-mix(in srgb, var(--color-canvas) 94%, transparent); + -webkit-backdrop-filter: none; + backdrop-filter: none; + } +} + .account-modal-overlay { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: var(--space-4); background: var(--color-scrim); animation: account-overlay-enter 180ms ease-out both; } .account-modal { width: min(100%, 560px); max-height: min(84vh, 760px); overflow-y: auto; padding: var(--space-8); border: 1px solid var(--color-border); border-radius: var(--radius-xl); background: var(--color-canvas); box-shadow: var(--shadow-elevated); animation: account-dialog-enter 180ms var(--ease-out) both; } /* Settings (2026-11-03 prototype). The frame stays a fixed 880×640 for every pane diff --git a/frontend/src/components/ui/alert-dialog.tsx b/frontend/src/components/ui/alert-dialog.tsx index 4fd13a4c1..2ac45c620 100644 --- a/frontend/src/components/ui/alert-dialog.tsx +++ b/frontend/src/components/ui/alert-dialog.tsx @@ -30,7 +30,7 @@ function AlertDialogOverlay({ readFileSync(join(root, path), "utf8"); + +function sourceFiles(dir: string): string[] { + return readdirSync(join(root, dir)).flatMap((name) => { + const path = join(dir, name); + if (statSync(join(root, path)).isDirectory()) return sourceFiles(path); + return /\.(tsx?|css)$/u.test(name) ? [path] : []; + }); +} + +const KIT = { + "src/components/ui/dialog.tsx": "dialog-overlay", + "src/components/ui/alert-dialog.tsx": "alert-dialog-overlay", + "src/components/ui/sheet.tsx": "sheet-overlay", + "src/components/ui/drawer.tsx": "drawer-overlay", +} as const; + +test("every kit overlay (Dialog, AlertDialog, Sheet, Drawer) uses the shared frosted .modal-scrim", () => { + for (const [file, slot] of Object.entries(KIT)) { + const source = read(file); + const overlay = source.slice(source.indexOf(`data-slot="${slot}"`)); + const className = overlay.slice(0, overlay.indexOf("className") + 400); + assert.match(className, /\bmodal-scrim\b/u, `${file} overlay must use .modal-scrim`); + // 原值:bg-black/10(淡黑,页面透出来);新值:.modal-scrim;原因:BUG-2276。 + assert.doesNotMatch(className, /\bbg-black\/\d+/u, `${file} overlay still carries the plain black scrim`); + } +}); + +test("no screen opens a modal from the raw primitives, so none bypasses the kit overlay", () => { + const raw = /from "@base-ui\/react\/(dialog|alert-dialog|drawer)"|from "vaul"/u; + const offenders = sourceFiles("src").filter((file) => !file.startsWith("src/components/ui/") && raw.test(read(file))); + assert.deepEqual(offenders, []); +}); + +test(".modal-scrim is the annual veil: canvas at 72% and a 6px blur, with solid fallbacks", () => { + const css = read("src/app/globals.css"); + const block = css.slice(css.indexOf(".modal-scrim {"), css.indexOf(".account-modal-overlay {")); + assert.match(block, /\.modal-scrim \{\s*background: color-mix\(in srgb, var\(--color-canvas\) 72%, transparent\);/u); + assert.match(block, /backdrop-filter: blur\(6px\)/u); + assert.match(block, /-webkit-backdrop-filter: blur\(6px\)/u); + assert.match(block, /@supports not \(\(backdrop-filter: blur\(1px\)\) or \(-webkit-backdrop-filter: blur\(1px\)\)\)/u); + assert.match(block, /@media \(prefers-reduced-transparency: reduce\)/u); + // The annual start overlay keeps the same look the shared scrim copies. + assert.match(read("src/app/annual-report.css"), /\.annual-veil \{[^}]*color-mix\(in srgb, var\(--color-canvas\) 72%, transparent\);[^}]*backdrop-filter: blur\(6px\);/u); +}); + +test("no stylesheet repaints a kit overlay with its own background (the BUG-2252 one-off is folded in)", () => { + for (const file of sourceFiles("src").filter((path) => path.endsWith(".css"))) { + assert.doesNotMatch(read(file), /\[data-slot="(dialog|alert-dialog|sheet|drawer)-overlay"\][^{]*\{[^}]*background/u, file); + } +}); + +test("the admin site's antd masks get the same frosted veil", () => { + const css = read("src/app/admin/admin.css"); + assert.match(css, /\.ant-modal-root \.ant-modal-mask,\s*\.ant-drawer \.ant-drawer-mask,\s*\.ant-image-preview-root \.ant-image-preview-mask \{\s*background: rgba\(243, 242, 238, \.72\);/u); + assert.match(css, /backdrop-filter: blur\(6px\)/u); +});