Skip to content

Fix #28: let the mobile backdrop cover the topbar too - #38

Open
xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-28-drawer-topbar
Open

xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-28-drawer-topbar

Conversation

@xiaoyao-666-coder

Copy link
Copy Markdown

问题

抽屉打开时顶栏 inert 但看似可点——不过核实后发现 issue 描述有三处与代码不符(以代码为准):

  • 遮罩其实存在:App.tsx:907 在 mobilePanel 打开时已渲染 <button className="mobile-panel-backdrop" onClick={closeMobilePanel}>,不是 issue 说的“零命中”。
  • inert 也已存在:约 379–392 行的 effect 在抽屉打开时给 .topbar 和 .chat-workspace 加 inert,关闭时移除。键盘焦点进不去顶栏,inert 在现代浏览器里也让顶栏按钮不再是点按目标。
  • 没有 --header-h: 56px 这个变量,抽屉 top:72px/64px 与顶栏 64px/58px 之间的几 px 间距是刻意的留白,不是 bug,没动。

真正的问题是遮罩的几何:styles.css 里 inset:64px 0 0(≤560px 时 inset:58px 0 0),遮罩从顶栏下方才开始,顶栏那 64px/58px 的条带没有被盖住。所以“假死感”的准确描述是:顶栏看起来完全正常、可点(未被遮罩压暗),但点上去什么都不发生(inert 拦住了点击,遮罩又没盖住它所以也不会关抽屉)。

修复

只改遮罩的覆盖范围,不动 inert 与焦点逻辑。选了“点击顶栏区域能关掉抽屉”这条验收路径(而不是给顶栏加变灰样式),因为遮罩本来就存在、且点遮罩关闭抽屉是用户已有的心智模型,改动最小:

  • frontend/src/styles.css(≤1020px 块):.mobile-panel-backdrop 的 inset:64px 0 0 改为 inset:0,并附注释说明原因;删除 ≤560px 块里 .mobile-panel-backdrop { inset:58px 0 0; } 的覆盖。
  • 层叠关系已核对:顶栏是静态定位无 z-index,遮罩 position:fixed; z-index:4 会盖住它并压暗(#14202b33),视觉上也明确表示“不可点”;两个抽屉 position:fixed; z-index:5 仍在遮罩之上,照常可交互;toast(z-index:10)不受影响。遮罩的 display:block 只在 ≤1020px 媒体查询内,桌面端无任何变化;切换到桌面宽度时原有监听器会关闭抽屉,修法只影响小屏。
  • App.tsx 未动:已有的 inert(键盘防护)与抽屉内焦点陷阱、Esc 关闭、恢复焦点逻辑全部保留。

验证

  • 前端:npm test 15 pass / 0 fail(基线 10 + 新增 5),npm run build(tsc -b && vite build)正常。新增测试覆盖:遮罩覆盖整个视口(含顶栏条带、无 64px/58px 残留)、遮罩只在移动端布局出现、抽屉 z-index 5 高于遮罩 z-index 4、抽屉打开时渲染遮罩按钮且点按关闭、顶栏 inert 逻辑未被破坏。
  • 后端:MEDGUIDE_MODE=test python -m pytest -q backend/tests 521 passed(基线,无后端改动)。
  • 未做真机/浏览器实点:云端没有真机,抽屉打开时点顶栏区域是否真的关闭抽屉、顶栏是否被遮罩压暗,需在手机浏览器上点一次确认。

已知遗留

  • 左右两个抽屉共用同一个遮罩按钮,修法对两者都适用;抽屉本身的打开/关闭与焦点行为未动。

Closes #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[中] 抽屉打开时顶栏未被遮罩、看似可点实则无响应(待真机验证)

1 participant