fix(messages): hide pointer-triggered focus ring#338
Open
youxikexue wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 Windows 桌面版或通过分享链接打开的网页端中,Agent 输出内容后,点击消息文本或正文空白处,整个消息滚动区域会出现焦点边框,边框包含右侧滚动条;点击区域外后消失。
复现步骤:
预期行为:鼠标点击正文后不显示键盘焦点提示,但仍可使用方向键、PageUp/PageDown 等按键滚动消息。通过 Tab 键进入消息区域时,应继续显示焦点提示。
原因
VirtualizedMessageThread为支持键盘滚动,给消息滚动视口设置了tabIndex=0,并在点击非交互正文时调用focus();视口同时使用focus-visible:ring-2提供键盘焦点提示。Chromium/WebView 会将鼠标事件中调用的程序化
focus()判定为:focus-visible,因此鼠标点击也触发了原本用于键盘导航的焦点环。相关行为由提交259989f引入。方案选择
考虑过以下方式:
tabIndex或点击聚焦:会破坏现有键盘滚动;本 PR 采用方案 3,保留原有键盘操作和无障碍设计,只修正不同输入方式下的视觉反馈。
改动
focus()前,为消息视口写入临时的鼠标焦点来源标记;:focus-visible时,通过局部样式隐藏焦点环;tabIndex、点击聚焦、交互元素过滤、右键处理和键盘焦点样式。改动仅涉及
VirtualizedMessageThread及对应回归测试,不修改全局 ScrollArea 或基础焦点样式。影响评估
验证
git diff --check均通过;