Repository navigation
fix(web): keep focus when reopening settings navigation - #1311
Conversation
Move focus to the collapse button before the reopen button hides, and stop hiding the collapsed sidebar with a delayed visibility transition. Keep a short retry for frames where the button cannot take focus yet. (cherry picked from commit 917b176) Co-Authored-By: Claude Code <noreply@anthropic.com>
crispinhu27
left a comment
There was a problem hiding this comment.
初审结论:未发现阻塞问题,批准。审查与验证对应 head 565ef075(base main 177d8815)。
审查范围
web/app.js:#settingsSidebarExpand的点击处理、setSettingsSidebarExpanded(expanded, focusToggle)新增的同步焦点转移与reopen.hidden时序,以及其他调用方(路由切换、resize、reduced-motion 变化、窄屏、access.js)。最终的hidden、inert、aria-hidden状态与改动前一致。web/app/navigation.css:去掉了visibility过渡。收起状态改为由clip-path+pointer-events:none+inert+aria-hidden隐藏,窄屏下的 fixed 浮层规则也核对过。- e2e 新断言:在应用 click 处理之后记录
activeElement,可以区分「同步转移」和「下一帧补焦点」两种行为。
实际验证(本机原生部署,MySQL 8.4.9 全新库,head 和 base 各起一套,使用隔离账号与测试数据)
webtest:head 284/284,base 284/284。go test ./web/...通过。- e2e
desktop settings两个用例在 head 上 ×5 共 10/10 通过;03-workbench-settings.spec.mjs全文件 6 通过、2 跳过(缺第二用户 Token)。 - 基线对照:用本 PR 的 spec 跑 base,新断言失败(
Expected: "settingsSidebarToggle",Received: "",点击时焦点在 body 上),其余用例结果相同。说明这个断言确实覆盖了本次修复。 - Chromium 实测(reduce / no-preference 各跑一遍,head 与 base 对照):
- 鼠标点击、Enter、Space 展开,以及 Safari 式点击(焦点在 body,
element.click()):head 在 click 返回时焦点已经在#settingsSidebarToggle上;base 此时在BODY,要等下一帧才补上。 - 焦点在主内容区时展开,焦点不被抢走,两边一致。
- 收起后虽然 computed
visibility从 hidden 变成了 visible,但连按 Tab 40 次没有一次落进侧栏,elementFromPoint也命中不到侧栏。1440 宽下收起和展开的截图与 base 逐像素一致(只有顶栏动态文本差 13px)。900 和 390 宽下的状态与截图与 base 相同。 - 全程没有页面 JS 错误。
- 鼠标点击、Enter、Space 展开,以及 Safari 式点击(焦点在 body,
- CI 16/16 success(包括
core)。main 之后前进到c3dd1b4d(#1285、#1304),它对web/app.js和web/index.html的改动只涉及执行机器页,与设置导航无关,merge-tree无冲突。
以上是在上述版本与环境下的验证结果,不代表覆盖了所有浏览器(没有在真实 Safari/Firefox 上验证)。
|
结论:建议合入 GitHub 拒绝了 Pull Request Review 接口(HTTP 403:Tencent 组织启用了 OAuth App 访问限制)。当前账号无法提交正式 Approve / Request changes。以下改为普通评论。 核对了 |
Robert0622
left a comment
There was a problem hiding this comment.
CR + 部署实测(head 565ef075):LGTM
说明:这次评审的 token 是 PR 作者本人的账号,GitHub 不允许作者 approve 自己的 PR,所以只发评论、不点 Approve。
代码审查
setSettingsSidebarExpanded(true, …)在把展开按钮设为hidden之前,先把焦点交给#settingsSidebarToggle。焦点不会先掉到body上再被 rAF 拉回来,读屏器也不会先读一遍 body。- 焦点不在展开按钮上(例如点击时焦点已经在别处)就不抢焦点;
focusToggle的 rAF 重试只在焦点确实掉到 body 时才跑,最多 30 帧。 - CSS 去掉了
visibility的延迟过渡。隐藏状态仍保留clip-path和pointer-events: none,侧栏的aria-hidden逻辑没变,收起时不会误点到侧栏内容。 - 与最新 main
f3d4f41a合并无冲突(git merge-tree)。
部署实测(本机原生部署 PR 和 main 两个实例,MySQL 8.4.7 全新库,Chromium)
| 场景 | PR | main |
|---|---|---|
e2e/ui/03-workbench-settings.spec.mjs(PR 版本,含新断言「点击展开按钮的那一刻焦点已在收起按钮上」) |
7 passed / 1 skipped | 新断言失败:点击时焦点不在 settingsSidebarToggle |
| 同一 spec 的 main 版本 | — | 7 passed / 1 skipped |
键盘 Enter 重新展开后焦点、URL 停在 #/settings |
✅ | ✅ |
回归:webtest 284/284 通过(main 285/285;本分支落后 main 3 个提交,数量差来自 main 新增的用例)。
结论:没有发现问题,可以合入。
|
Pushed the narrow-viewport follow-up in |
crispinhu27
left a comment
There was a problem hiding this comment.
复审结论:未发现阻塞问题,批准。审查与验证对应 head fd4b5955(base main 177d8815)。
复审背景
- 之前在
565ef075上的 APPROVE(6043658270)被新推送 dismiss,没有遗留的 Request Changes 问题。本轮重点审查增量提交fd4b5955,同时复测之前已验证的焦点行为。
审查范围(增量)
web/app/navigation.css:删掉了@media (max-width: 1000px) { .settings-navigation-reopen { display: none } },加上flex-shrink: 0。[hidden]规则仍然保留,所以非设置视图和侧栏展开时按钮照样隐藏;按钮由setSettingsSidebarExpanded统一控制hidden,窄屏和宽屏走的是同一套逻辑。- 结合
web/app/frame.css核对了窄屏规则:≤1000px 时.platform-rail是display:none。在 base 上,直接打开#/settings时侧栏默认收起,展开按钮又被这条 media 规则隐藏,结果设置导航无法再打开。本次改动修复的正是这个问题。 - e2e 新增 900/480px 用例:在 reduced motion 下,用键盘 Enter 收起、Space 展开,并断言焦点落点和 URL 不变。
- main 现已前进到
848793b3,期间对web/app.js和web/index.html的改动只涉及 toast、沙箱选择和执行机器页,与设置导航无关,merge-tree无冲突。
实际验证(本机原生部署,MySQL 8.4.7 全新库,head 和 base 各起一套,使用隔离账号和测试数据)
webtest284/284,go test ./web/...通过。- e2e
03-workbench-settings.spec.mjs,head 跑 ×3:3 个设置导航用例(desktop、900px、480px)9/9 全部通过。用同一份 spec 跑 base:这 3 个用例都失败,说明新断言确实覆盖了本次修复。 - 同文件中「personal credentials: the add wizard…」在 head 上的 ×3 里有 1 次超时(卡在
confirm-delete点击)。单独重跑 head ×5 全部通过,base ×5 也有 1 次超时,属于与本 PR 无关的既有偶发问题。 - Chromium 实测,在 360/480/760/900/1000/1001/1440px 下各跑 reduce 和 no-preference 两遍,head 与 base 对照:
- head 在 ≤1000px 直接打开设置时侧栏收起,展开按钮可见(44×44,
elementFromPoint命中按钮本身)。键盘 Enter/Space 和鼠标点击都能展开,展开后焦点在#settingsSidebarToggle;收起后焦点回到展开按钮;URL 始终停在#/settings。在窄屏侧栏中点「执行机器」后,侧栏收起,焦点落在展开按钮上。 - base 在 ≤1000px 下展开按钮不可见,侧栏无法打开。
- 顶栏没有元素重叠,也没有横向溢出(360px 时最右边元素在 348px 处)。切到非设置视图后展开按钮隐藏。≥1001px 的行为与 base 一致。全程没有页面 JS 错误。
- head 在 ≤1000px 直接打开设置时侧栏收起,展开按钮可见(44×44,
- CI 16/16 success。
以上是在上述版本和环境下的验证结果,不代表覆盖了所有浏览器(没有在真实 Safari/Firefox 或真机触屏上验证)。
|
Re-review of Scope: only the delta Deployed test (this head built locally, fresh MySQL 8.4.7, first account created via
Layout checks at 320/360/480/900/1000px with the sidebar collapsed: the reopen button overlaps no other topbar child, the topbar and document have no horizontal overflow, and the mobile CI: 16/16 checks pass on Note: this token is the PR author's account, so this is a comment rather than a formal Approve. Screenshots are kept outside the repo; no screenshot branch was created. |
What changed
#settingsSidebarTogglebefore the expand button is hidden, so keyboard and pointer users never land on<body>.visibility; the collapsed sidebar staysinert.Split out of #1267 (originally commit 917b176 there) at reviewer request, since it is unrelated to long prompt delivery.
Validation
webtest284/284,go test ./web/...pass.desktop settingscases ine2e/ui/03-workbench-settings.spec.mjs×5 each: 10/10 pass, including the new "focus is already on the collapse button when clicked" assertion.<body>all focus#settingsSidebarToggle; reopening while focus is in the main content does not steal it; no JS errors.Safety
🤖 Generated with Claude Code