diff --git a/raven-app/src/components/feature/chat/ChatInput/ChannelMentionList.tsx b/raven-app/src/components/feature/chat/ChatInput/ChannelMentionList.tsx index b609cecec..209d4618c 100644 --- a/raven-app/src/components/feature/chat/ChatInput/ChannelMentionList.tsx +++ b/raven-app/src/components/feature/chat/ChatInput/ChannelMentionList.tsx @@ -5,6 +5,7 @@ import { ReactRendererOptions } from '@tiptap/react' import { clsx } from 'clsx' import { forwardRef, useEffect, useImperativeHandle, + useRef, useState, } from 'react' @@ -81,10 +82,16 @@ export default forwardRef((props: ReactRendererOptions['props'], ref) => { const MentionItem = ({ item, index, selectItem, selectedIndex, itemsLength }: { itemsLength: number, selectedIndex: number, index: number, item: ChannelListItem, selectItem: (index: number) => void }) => { + const ref = useRef(null) + + useEffect(() => { + if (index === selectedIndex) ref.current?.scrollIntoView({ block: 'nearest' }) + }, [selectedIndex, index]) return { {props?.items.length ? props.items.map((item: UserFields, index: number) => ( @@ -85,9 +86,16 @@ const MentionItem = ({ item, index, selectItem, selectedIndex, itemsLength }: { const isActive = useIsUserActive(item.name) + const ref = useRef(null) + + useEffect(() => { + if (index === selectedIndex) ref.current?.scrollIntoView({ block: 'nearest' }) + }, [selectedIndex, index]) + return