Skip to content

fix(groups): scroll active @mention option into view on keyboard navigation - #1729

Open
lonehsigle wants to merge 1 commit into
BytePioneer-AI:mainfrom
lonehsigle:fix/group-mention-keyboard-scroll
Open

lonehsigle wants to merge 1 commit into
BytePioneer-AI:mainfrom
lonehsigle:fix/group-mention-keyboard-scroll

Conversation

@lonehsigle

Copy link
Copy Markdown
Contributor

Summary

When typing @ in a group chat with enough members to overflow the .mentionPopover (max-height: 220px; overflow-y: auto), pressing ArrowDown / ArrowUp moved mentionIndex without scrolling the popover container because focus remains in the composer <textarea> (combobox pattern). Users had to scroll the list manually with the mouse to see the highlighted member.

Changes

  • apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx:
    • Attach mentionPopoverRef to the role="listbox" container and scroll the active [role="option"][aria-selected="true"] element into view via scrollIntoView({ block: "nearest" }) whenever the active mention option changes (matching PopupSelectView.tsx / MenuView.tsx).
    • Clamp activeMentionIndex to mentionCandidates.length - 1 across rendering and ArrowDown / ArrowUp / Enter / Tab handlers so dynamic roster shrinkage cannot leave the highlight out of bounds.
  • apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css:
    • Add scroll-margin-block: 4px to .mentionOption to align with the 4px vertical padding on .mentionPopover when scrolled to either edge.

Related issues

无 / N/A

UI Demo

Sanitized screenshots captured in an isolated Web instance (sidebar collapsed, 12 synthetic members / 13 candidates):

Before (ArrowDown ×10: 10-Juliet off-screen, scrollTop: 0) After (ArrowDown ×10: 10-Juliet scrolled into view)
Before desktop After desktop ArrowDown
After (ArrowUp wrap from top to last item 12-Lima) After (Mobile 390×844, ArrowDown ×10)
After desktop wrap up After mobile ArrowDown

Test plan

  • npx prettier --check apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css — passed
  • node tools/check-boundaries.mjs — passed
  • npm run build:web:ui — passed
  • npx vitest run --config tests/vitest.config.js apps/web-ui/packages/client/ui-codexhost/test/group-reply-target.test.ts apps/web-ui/packages/client/ui-codexhost/test/group-ime-guard.test.ts — 2 files, 34/34 tests passed
  • Isolated Web browser verification (macOS, Chromium via ego-browser, desktop + mobile 390×844, 12-member group room):
    • Reproduced baseline bug (ArrowDown ×10 left scrollTop === 0 with 10-Juliet outside the visible viewport).
    • Verified post-fix ArrowDown stepping (scrollTop: 141 / 205), bottom-to-top wrap (scrollTop: 0), top-to-bottom ArrowUp wrap (scrollTop: 205), stepping back to top, query filtering (@02), Enter insertion, Escape dismiss, mouse click selection, zero outer page scroll (window.scrollY === 0), and zero uncaught page errors.
  • Full-repo CI (lint, typecheck, full test, Rust checks) — left to GitHub Actions per AGENTS.md.

@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 修复群聊中 @名称候选列表缩短后,键盘选择可能指向无效候选项的问题。
    • 移动键盘选中项时,候选项会自动滚动至可视区域;当前选中状态与高亮显示保持一致。

群聊编辑器现在会将提及候选索引限制在当前候选范围内,并将选中项滚动到可视区域。键盘选择、aria-selected 和活动样式均使用限制后的索引。

Changes: 提及候选项交互

Layer / File(s) Summary
候选项索引与可视状态
apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx, apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css
编辑器为候选列表绑定容器引用,并将候选索引限制在当前候选范围内。上下键、Enter 和 Tab 使用限制后的索引;选中项滚动到可视区域,aria-selected 和活动样式也依据该索引更新。候选项样式新增块方向 4px 滚动边距。

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 0aa8e

This change keeps the highlighted @mention visible during keyboard navigation and prevents an out-of-range highlight when the member list shrinks. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(groups): scroll active @mention option into view on keyboard navigation”与变更内容直接相关。变更在 GroupComposer.tsx 中为 @ 提及弹层的选中项添加滚动逻辑,并在 GroupChatPage.module.css 中为 .mentionOption 添加 scroll-margin-block,…
Description check Passed 描述与变更内容相关。描述说明了问题(键盘上下移动时弹层不滚动)、GroupComposer.tsx 中的 ref 与 scrollIntoView 修改、索引钳制逻辑、CSS 中的 scroll-margin-block 变更,并列出了测试计划与浏览器验证结果。描述内容完整,与变更一致。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“fix(groups): scroll active @mention option into view on keyboard navigation”与变更内容直接相关。变更在 GroupComposer.tsx 中为 @ 提及弹层的选中项添加滚动逻辑,并在 GroupChatPage.module.css 中为 .mentionOption 添加 scroll-margin-block,主要目的与标题一致。标题使用 conventional commit 格式,简洁且具体。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 24ab436 and 0aa8e2b.

Files selected for processing: 2

  • apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css
  • apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 4

  • GitHub Check: CodeRabbit
  • GitHub Check: Static checks
  • GitHub Check: Web Host tests
  • GitHub Check: Vitest
Additional context used

Code guidelines: 2

apps/web-ui/AGENTS.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 2

Source excerpt: Reuse components and icons from `@deepseek-ai/dsh-client-ui-primitives` (`packages/client/ui-primitives/src/index.ts`); never ship OS-native `` (use `SelectField` or `Menu`). CodeRabbit inference engine (apps/web-ui/AGENTS.md) Files: apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx Source excerpt: Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly. CodeRabbit inference engine (AGENTS.md) Files: apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupChatPage.module.css apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx Learnings: 1 Common learnings Learnt from: CR Repo: BytePioneer-AI/codex-host PR: 0 File: .agents/skills/codexhost-code-review/SKILL.md:0-0 Timestamp: 2026-12-05T16:51:14.466Z Learning: Applicability reference: AGENTS.md: # Repository Guidelines ## Repository Skills | Task | Skill | | --- | --- | | Reviewing a PR or local diff for correctness and boundaries | [codexhost-code-review](.agents/skills/codexhost-code-review/SKILL.md) | Source excerpt: # codexhost 代码审查 ## 人工检查 - **UI 底线与演示图**:涉及可见 UI 改动(Web / Desktop / Android / Renderer / Console)的 PR,对照 [DESIGN.md](../../../DESIGN.md) 检查底线(不使用原生 `<select>`、复用 `ui-primitives`、使用语义 token、亮暗色与 390px 移动端可用、无堆叠边框与 Unicode 字符图标),并确认 PR 描述中已附带脱敏演示图(截图或录屏);无视觉变化的纯逻辑改动应注明 `No visual changes: <原因>`。 Additional comments: 1 apps/web-ui/packages/client/ui-codexhost/src/client/groups/GroupComposer.tsx: 1 405-405: Functional Correctness The comment asks whether scrollIntoView({ block: "nearest" }) moves an outer container. The supplied code does not establish a path where this happens. The call moves a scrollable ancestor only when the selected option is outside that ancestor's visible area. The option sits inside the mention popover, and the comment identifies no case where the popover itself is clipped. The concern depends on a layout premise that the comment does not establish. It is therefore a speculative question rather than a supported defect.

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