From 6ed6d564bca7abe8d586f4b2c9c806dd1b0732bd Mon Sep 17 00:00:00 2001 From: Zhenxian Liang Date: Mon, 16 Nov 2026 19:50:09 +0800 Subject: [PATCH 1/2] Fix #28: let the mobile backdrop cover the topbar too --- frontend/src/styles.css | 8 ++- frontend/tests/mobile-panel-backdrop.test.mjs | 58 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 frontend/tests/mobile-panel-backdrop.test.mjs diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 2523191..380cc8d 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -355,7 +355,12 @@ button.starter-prompt:focus-visible .starter-prompt-action,.inline-citations:foc .right-panel { right:12px; left:auto; } .left-rail.mobile-visible { --drawer-offset:-12px; display:flex; animation:drawer-arrive var(--motion-base) var(--ease-out); } .right-panel.mobile-visible { --drawer-offset:12px; display:block; animation:drawer-arrive var(--motion-base) var(--ease-out); } - .mobile-panel-backdrop { display:block; position:fixed; inset:64px 0 0; z-index:4; width:100%; padding:0; background:#14202b33; border:0; animation:backdrop-arrive var(--motion-fast) ease-out; } + /* The backdrop covers the whole viewport, including the topbar strip: + the topbar is inert while a panel is open, so without a backdrop + over it a tap on the topbar would do nothing at all (issue #28) -- + it must instead reach this button and close the panel. The drawers + (z-index 5) stay above the backdrop (z-index 4) and keep working. */ + .mobile-panel-backdrop { display:block; position:fixed; inset:0; z-index:4; width:100%; padding:0; background:#14202b33; border:0; animation:backdrop-arrive var(--motion-fast) ease-out; } .mobile-trigger,.secondary-button { display:inline-flex; } .close-mobile { display:inline-grid; } .icon-button { min-width:40px; min-height:40px; } @@ -408,7 +413,6 @@ button.starter-prompt:focus-visible .starter-prompt-action,.inline-citations:foc .secondary-button { min-height:35px; padding:0 8px; font-size:11px; } .left-rail,.right-panel { top:64px; bottom:7px; left:7px; width:min(354px,calc(100vw - 14px)); } .right-panel { left:auto; right:7px; } - .mobile-panel-backdrop { inset:58px 0 0; } .messages-scroller { padding:20px 15px; } .is-welcome .messages-scroller { padding:1px 18px 18px; } .welcome-view { margin:0 auto; padding:13px 0 10px; } diff --git a/frontend/tests/mobile-panel-backdrop.test.mjs b/frontend/tests/mobile-panel-backdrop.test.mjs new file mode 100644 index 0000000..50b3252 --- /dev/null +++ b/frontend/tests/mobile-panel-backdrop.test.mjs @@ -0,0 +1,58 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import { test } from "node:test"; + +// Issue #28: while a mobile drawer is open the topbar looked clickable +// but a tap on it did nothing -- the backdrop stopped below the topbar +// (inset:64px / inset:58px) while the topbar itself was inert. The fix +// is to let the backdrop cover the whole viewport, so a tap anywhere +// outside the drawer -- topbar included -- closes the panel. There is +// no DOM in this suite, so these tests assert on the shipped source and +// styles instead of a live click. +const styles = await readFile(new URL("../src/styles.css", import.meta.url), "utf8"); +const appSource = await readFile(new URL("../src/App.tsx", import.meta.url), "utf8"); + +function backdropRules() { + const rules = []; + const pattern = /\.mobile-panel-backdrop\s*\{([^}]*)\}/g; + let match; + while ((match = pattern.exec(styles)) !== null) rules.push(match[1]); + return rules; +} + +test("backdrop covers the whole viewport, including the topbar strip", () => { + const rules = backdropRules(); + assert.ok(rules.length > 0, "expected a .mobile-panel-backdrop rule"); + for (const rule of rules) { + assert.match(rule, /(^|;)\s*inset:\s*0\s*(;|$)/, `backdrop rule must start at the viewport top: ${rule}`); + assert.doesNotMatch(rule, /inset:\s*(64|58)px/, `backdrop must not stop below the topbar: ${rule}`); + } +}); + +test("backdrop is only shown in the mobile layout", () => { + assert.match(styles, /\.mobile-panel-backdrop,\s*\.close-mobile\s*\{\s*display:\s*none\s*;?\s*\}/); + const mediaIndex = styles.indexOf("@media (max-width:1020px)"); + const ruleIndex = styles.indexOf(".mobile-panel-backdrop { display:block"); + assert.ok(mediaIndex >= 0 && ruleIndex > mediaIndex, "backdrop display:block must live inside the <=1020px block"); +}); + +test("drawers stay above the backdrop so they remain usable", () => { + const backdrop = backdropRules().find((rule) => rule.includes("display:block")); + assert.match(backdrop, /z-index:\s*4\b/); + const drawerRule = styles.match(/\.left-rail,\s*\.right-panel\s*\{([^}]*)\}/); + assert.ok(drawerRule, "expected the shared drawer rule"); + assert.match(drawerRule[1], /z-index:\s*5\b/, "drawers must paint above the backdrop"); +}); + +test("backdrop is rendered while a panel is open and closes it on tap", () => { + assert.ok( + appSource.includes('{mobilePanel && @@ -922,12 +1234,25 @@ function App() { -
这次对话
+
历史对话
- + {sessions.length === 0 ? ( + + ) : ( + sessions.map((item) => ( + + )) + )}
如何描述问题 @@ -974,7 +1299,7 @@ function App() {

可以从哪里不舒服、持续多久开始。用药或检查方面的疑问,也可以直接提问。

先从一个具体问题开始,信息会随着对话逐步补齐。
- :
{formatDateDivider(messages[0]?.timestamp ?? Date.now())}
} + :
{formatDateDivider(messages.find((message) => message.role === "user")?.timestamp ?? messages[0]?.timestamp ?? Date.now())}
} {(!isWelcome ? messages : []).map((message) => (
{message.role === "assistant" &&
} @@ -985,7 +1310,30 @@ function App() { )} {message.role === "assistant" && message.latency !== undefined &&
响应 {Math.round(message.latency)} ms
} - {message.role === "assistant" && message.id !== "welcome" &&
这条回答有帮助吗?
} + {message.role === "assistant" && message.id !== "welcome" &&
这条回答有帮助吗?
} + {message.role === "assistant" && message.id !== "welcome" && feedbackComment.openMessageId === message.id && ( +
+ +