From 8815d27e1d85a2a07db0a0d2e5804b282b428c59 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Wed, 1 Apr 2026 19:35:23 +0800 Subject: [PATCH] fix(web): use ActorAvatar in mention picker and fix keyboard scroll - Replace inline initials/Bot icon with ActorAvatar component so mention suggestions show real profile pictures consistently - Add scrollIntoView on keyboard navigation so the selected item stays visible when the list overflows Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/common/mention-suggestion.tsx | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/web/components/common/mention-suggestion.tsx b/apps/web/components/common/mention-suggestion.tsx index b00b4c1d..b0092f78 100644 --- a/apps/web/components/common/mention-suggestion.tsx +++ b/apps/web/components/common/mention-suggestion.tsx @@ -2,15 +2,18 @@ import { forwardRef, + useCallback, useEffect, useImperativeHandle, + useRef, useState, } from "react"; -import { Bot, Hash } from "lucide-react"; +import { Hash } from "lucide-react"; import { ReactRenderer } from "@tiptap/react"; import { computePosition, offset, flip, shift } from "@floating-ui/dom"; import { useWorkspaceStore } from "@/features/workspace"; import { useIssueStore } from "@/features/issues"; +import { ActorAvatar } from "@/components/common/actor-avatar"; import type { SuggestionOptions, SuggestionProps } from "@tiptap/suggestion"; // --------------------------------------------------------------------------- @@ -41,15 +44,23 @@ export interface MentionListRef { const MentionList = forwardRef( function MentionList({ items, command }, ref) { const [selectedIndex, setSelectedIndex] = useState(0); + const itemRefs = useRef<(HTMLButtonElement | null)[]>([]); useEffect(() => { setSelectedIndex(0); }, [items]); - const selectItem = (index: number) => { - const item = items[index]; - if (item) command(item); - }; + useEffect(() => { + itemRefs.current[selectedIndex]?.scrollIntoView({ block: "nearest" }); + }, [selectedIndex]); + + const selectItem = useCallback( + (index: number) => { + const item = items[index]; + if (item) command(item); + }, + [items, command], + ); useImperativeHandle(ref, () => ({ onKeyDown: ({ event }) => { @@ -81,29 +92,23 @@ const MentionList = forwardRef(
{items.map((item, index) => (