Skip to content

Commit f72d3d4

Browse files
updated to auto-scroll even when a response is received
1 parent df74dca commit f72d3d4

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

app/classrooms/[classroomId]/chat/auto-scroll.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@
22

33
import { ScrollArea } from "@/shared/components/ui/scroll-area";
44
import { useEffect, useRef } from "react";
5+
import { RagFlowMessage } from "@shared/lib/ragflow/chat/chat-client";
56

67
interface AutoScrollProps {
78
children: React.ReactNode;
8-
isMessageSent: boolean;
9+
messages: RagFlowMessage[];
910
}
1011

11-
export default function AutoScroll({
12-
children,
13-
isMessageSent,
14-
}: AutoScrollProps) {
12+
export default function AutoScroll({ children, messages }: AutoScrollProps) {
1513
const scrollRef = useRef<HTMLDivElement>(null);
1614

1715
useEffect(() => {
18-
if (isMessageSent) {
19-
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
20-
}
21-
}, [isMessageSent]);
22-
16+
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
17+
}, [messages]);
2318
useEffect(() => {
2419
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
2520
}, []);

0 commit comments

Comments
 (0)