Repository navigation
Restore focus to the Goal details opener - #9441
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
从概览或窄屏会话阅读 Goal 详情、随后继续使用键盘的用户。 当点击详情按钮没有把焦点移到按钮时,旧 drawer 记住了先前聚焦的标签。按 Escape 后焦点退回该标签,用户下次 Tab 从错误位置开始。
Goal 详情关闭后恢复触发按钮的键盘焦点。打开后禁用原按钮,按 Escape 回到当前 Goal 标签。关闭帧之前显式聚焦外部标签时,该焦点保留。两侧未改动的 Task inspector 返回场景都通过。 在同一浏览器场景中,旧版未通过 Overview 按钮的焦点断言,新版关闭后聚焦发起操作的按钮。390px 会话的 masthead 按钮也通过了 Close button 路径。 独立运行范围为隔离源码 worktree 的 Vite Dashboard 和 Chromium,使用合成状态与远端只读路由。签名 App 安装、WebKit/VoiceOver 和生产数据完整性留在对应验收。 设计与可访问性要求
改动思路 / Approach
两个 Goal 详情按钮携带 event.currentTarget。页面在目标数据刷新时保留该引用,已存在的 ContextDrawer 继续拥有进入、退出和 fallback 焦点。 单靠 document.activeElement 无法识别不移动焦点的点击。把真实触发按钮传给现有 drawer 即可,无需全局焦点记录或新生产状态。
GoalOverview / GoalMastheadIdentity → WorkspaceDrawerSelection → ContextDrawer → closeDrawer。
具体改动 / Changes
精确提交 94dabbaacdcfd6346078d16f5f1952f5496695f4,基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。7 个文件增加 59 行、删除 17 行。生产层传递两处按钮、保留 Goal 投影中的可选引用并交给原 focus effect。其余是浏览器验收。
GoalOverview。将概览入口的 event.currentTarget 交给页面。 源码GoalMastheadIdentity。将 390px 会话信息按钮引用传给页面。 源码drawerSelection。Goal 数据更新时保留可选按钮引用。 源码ContextDrawer focus effect。优先记录明确发起者,其他选择继续使用当前活动元素。 源码closeDrawer。先保留已有外部焦点,恢复失败时聚焦当前标签或任务看板。 源码
对主干的风险 / Risks
共享 drawer 的焦点行为可能影响其他选择。独立运行 Goal Workspace M2,目标基线用同一测试断言复现失败,当前头全部通过。Task inspector 返回在基线与当前头均通过。TypeScript 和 diff 检查通过。本机 diff 选路 premerge 通过。 作者提供了独立的打包证据,已发布签名 App 仍待采用。 通过受控 click 固定“点击前焦点仍在标签”的前提,用相同测试和两个独立源码 worktree 验证。
特殊路径中,目标不可聚焦时按现有 fallback 处理。用户已将焦点移到 drawer 外时保留其选择。详情打开和关闭没有新增写入或授权请求。
我的整体评价 / Verdict
APPROVE。 使用元素引用定位真实触发点,继续复用已有 fallback 和外部焦点优先规则。非 Goal drawer 仍从活动元素确定回退。 查看了完整桌面概览、390px 会话返回和窄屏已展开详情。桌面焦点环回到 Goal 信息按钮,窄屏证据、长 owner 与失败状态仍可阅读。 独立图片来自开发构建中的合成工作区。签名 App 安装和 VoiceOver 未覆盖。
English verdict: APPROVE at 94dabba. The same browser assertion reproduces the baseline focus bug. The reviewed head restores the actual Goal details opener and preserves the shared Task inspector return path.
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
从 Goal 概览的信息按钮或 390px 会话 masthead 打开详情,并用 Escape、关闭按钮或键盘继续浏览的用户。
同一次 pointer activation 前,焦点停留在当前 Goal tab。旧实现关闭 drawer 后回到 tab;新实现记录被点击的 Goal 信息或 masthead 按钮,关闭后精确返回该按钮。
桌面概览 Escape、390px masthead 关闭按钮和键盘 Enter 打开都返回精确 opener;opener 不可用时返回当前 Goal tab 或任务看板;用户已把焦点移到 drawer 外时保留外部焦点。
不改变 drawer 的布局、内容、异步读取、写入权限或非 Goal selection 的返回规则,也不新增全局焦点管理器。
改动思路 / Approach
把实际 opener 作为瞬时 selection 证据交给既有 ContextDrawer focus owner,是满足 exact originating control 的最小完整机制。
仅改变两个 Goal 入口、Goal selection 和共享 drawer 的返回证据;布局、数据读取、权限和其他 drawer selection 契约保持不变。
入口是 GoalOverview 的信息按钮和 390px GoalMastheadIdentity 信息按钮。权威输入为 被点击的 HTMLButtonElement,以及现有 WorkspaceDrawerSelection 和 ContextDrawer returnFocusRef。决定边界:ContextDrawer focus effect 记录 opener;closeDrawer 决定优先保留外部焦点、恢复 opener 或使用现有 fallback。结果:仅更新前端 drawer selection 与焦点;没有后端写入、读取授权或持久状态变化。消费方:drawer 打开后的 title focus 和关闭后的 originating control、Goal tab 或 task board focus。失败与重试:opener 不可聚焦时 closeDrawer 先尝试返回,再聚焦当前 Goal tab 或可见 task board;外部有效焦点直接保留。
具体改动 / Changes
按 docs/development/design.md 的 revision beb32ccb74e186d5405a6de9d42258e5d91797f5 核对,exact-originating-control / desktop-and-narrow / failure-and-user-focus 分别对应下面的行为与验证。
关键代码讲解
GoalOverview.onOpenDetails:在详情按钮 click 时传递 event.currentTarget,而不是无参数回调;从只请求打开 Goal 详情变为同时携带真实触发按钮。GoalMastheadIdentity.onOpenDetails:让 390px 会话 masthead 的信息按钮把自身引用交给页面;窄屏关闭路径不再依赖点击前遗留的 activeElement。WorkspaceDrawerSelection.goal.openingControl:在既有 Goal drawer selection 上携带可选瞬时 opener;drawer selection 现在能区分实际触发控件和无关的先前焦点。ContextDrawer focus effect and closeDrawer:优先记录 Goal opener,并在关闭时保留外部焦点、恢复 opener 或使用现有 fallback;焦点恢复从 activeElement 猜测变为显式触发引用加既有有效性检查。verifyGoalDetails:在真实 Chromium 中让 Goal tab 保持焦点后触发详情,验证 Escape、fallback 和外部焦点优先;测试不再依赖 button.click 顺带移动焦点,而是固定原始缺陷前提并覆盖 390px masthead。
变更共 7,59 additions、17 deletions。六个 Dashboard 生产文件把实际 opener 传入既有 selection/drawer focus owner;一个浏览器场景增加桌面、390px、fallback、外部焦点和原有 Task inspector 回归断言。
exact-originating-control:关闭 Goal 详情后,焦点返回实际发起打开的控件,而不是仅依赖先前 activeElement;当前为 implemented。desktop-and-narrow:桌面概览与 390px 窄屏 masthead 使用同一返回合同;当前为 implemented。failure-and-user-focus:opener 不可聚焦时走现有 fallback,用户已把焦点移到外部时不得被 drawer 覆盖;当前为 implemented。
对主干的风险 / Risks
最强回归场景:drawer 关闭后把焦点送到错误控件,或在 opener 不可用时抛出错误并丢失键盘位置。触发状态:点击不移动焦点、opener 随后 disabled、用户主动移动外部焦点,或 Goal 数据刷新重建 selection。修复边界:openingControl 随 selection 刷新保留;closeDrawer 检查真实 focus 结果并在失败时使用已有 fallback。影响范围:Personal Workspace Goal 详情和共享 ContextDrawer 的所有关闭方式。可观察性:document.activeElement 是否等于 exact opener、Goal tab 或外部控件,可直接在 Chromium 中读取。恢复路径:关闭并重新打开详情可恢复;变更没有持久化或迁移。
changed_invariant_positive=passed (Packaged Chromium scenario passed; Overview Escape and masthead close button returned to their exact Goal buttons.);material_negative_or_failure=passed (Disabled opener returned to the active Goal tab; moving focus outside the drawer before close retained that external control.);related_task_inspector_and_unit=passed (Dashboard TypeScript/Vite/Chat build passed and 10 M2 tests passed.);repository_required_checks=passed (Premerge selected checks passed 5/5 with zero manual holds; diff check was clean.);render_budget=passed (Desktop and 390px compositions stayed within render limits and recorded no mutation/effect writes.)。
- PASSED · Desktop and 390px Goal details close to the exact opener:Packaged Chromium scenario passed; Overview Escape and masthead close button returned to their exact Goal buttons.
- PASSED · Unavailable opener uses fallback and valid external focus is preserved:Disabled opener returned to the active Goal tab; moving focus outside the drawer before close retained that external control.
- PASSED · Shared drawer compatibility, TypeScript build and M2 model tests:Dashboard TypeScript/Vite/Chat build passed and 10 M2 tests passed.
- PASSED · Diff-selected repository premerge and diff hygiene:Premerge selected checks passed 5/5 with zero manual holds; diff check was clean.
- PASSED · Desktop and narrow synthetic Goal workspace keep no-write and render budgets:Desktop and 390px compositions stayed within render limits and recorded no mutation/effect writes.
我的整体评价 / Verdict
长程效果判断为 preserved:修复只延续既有 drawer 的焦点 owner,使长程阅读和后续键盘操作从用户真正选择的入口继续,不引入持久状态或新的 continuation 规则。用户体验判断为 improved:键盘和辅助技术用户可以稳定回到实际打开的入口,桌面与窄屏路径一致,且不会覆盖用户主动移动的外部焦点。截图确认桌面与 390px 场景产生了可读界面,但本 diff 不改变布局或样式;关键验收是真实 Chromium 中的 exact focus target。
当前 head 在桌面和 390px 都恢复实际 opener,同时现有 fallback、外部焦点优先和 Task inspector 路径保持通过。
English verdict: APPROVE at a615901. Goal details now return focus to the exact opening control on desktop and narrow screens. Packaged browser focus, fallback, external-focus, compatibility, build and premerge checks pass at the reviewed head.
User-visible behavior
When a click opens Goal details without moving keyboard focus, closing the drawer should return focus to the button that opened it. The Overview entry and the narrow conversation masthead now pass their actual buttons to the shared drawer. When the opener is unavailable, focus goes to the existing fallback. A valid focus move outside the drawer takes precedence.
Verification
50aa5b4fd1c88b7225fc30e58423120e3ad5d426. The matching assertion passes on94dabbaacdcfd6346078d16f5f1952f5496695f4along with the 390px masthead, Escape, close button, unavailable opener, external focus and bilingual detail checks.Visual evidence
These images use the public synthetic fixture. The desktop comparison shows where Escape places keyboard focus. The two 390px views show the masthead entry and the expanded original evidence.
Capture manifest and tested revisions
Signed LoopX 2.4.1 exhibited the baseline behavior. The images and passing results are from the packaged candidate. Signed App adoption can be verified once a release includes the change.