Skip to content

Commit 949940e

Browse files
committed
smol fix
1 parent ae98c67 commit 949940e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

apps/portal/src/components/AI/chat.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,13 @@ export function Chat() {
134134
);
135135

136136
useEffect(() => {
137-
const timer = setTimeout(() => {
138-
if (lastMessageRef.current) {
139-
lastMessageRef.current.scrollIntoView({
140-
behavior: "smooth",
141-
block: "end",
142-
});
143-
}
144-
}, 100);
145-
146-
return () => clearTimeout(timer);
147-
}, []);
137+
if (lastMessageRef.current && messages.length > 0) {
138+
lastMessageRef.current.scrollIntoView({
139+
behavior: "smooth",
140+
block: "start",
141+
});
142+
}
143+
}, [messages.length]);
148144

149145
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
150146
setInput(e.target.value);

0 commit comments

Comments
 (0)