Skip to content

Commit a818ac7

Browse files
committed
fix: fix resize scrolling issue
1 parent 517d0de commit a818ac7

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

chat/src/components/message-list.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ interface MessageListProps {
2020

2121
export default function MessageList({ messages }: MessageListProps) {
2222
const scrollAreaRef = useRef<HTMLDivElement>(null);
23-
// Avoid the message list to change its height all the time. It causes some
24-
// flickering in the screen because some messages, as the ones displaying
25-
// progress statuses, are changing the content(the number of lines) and size
26-
// constantily. To minimize it, we keep track of the biggest scroll height of
27-
// the content, and use that as the min height of the scroll area.
28-
const contentMinHeight = useRef(0);
2923

3024
// Track if user is at bottom - default to true for initial scroll
3125
const isAtBottomRef = useRef(true);
@@ -67,11 +61,6 @@ export default function MessageList({ messages }: MessageListProps) {
6761
const isNewUserMessage =
6862
messages.length > 0 && messages[messages.length - 1].role === "user";
6963

70-
// Update content min height if needed
71-
if (currentScrollHeight > contentMinHeight.current) {
72-
contentMinHeight.current = currentScrollHeight;
73-
}
74-
7564
// Auto-scroll only if:
7665
// 1. It's the first render, OR
7766
// 2. There's new content AND user was at the bottom, OR
@@ -104,9 +93,7 @@ export default function MessageList({ messages }: MessageListProps) {
10493
return (
10594
<div className="overflow-y-auto flex-1" ref={scrollAreaRef}>
10695
<div
107-
className="p-4 flex flex-col gap-4 max-w-4xl mx-auto"
108-
style={{ minHeight: contentMinHeight.current }}
109-
>
96+
className="p-4 flex flex-col gap-4 max-w-4xl mx-auto transition-all duration-300 ease-in-out min-h-0">
11097
{messages.map((message) => (
11198
<div
11299
key={message.id ?? "draft"}

0 commit comments

Comments
 (0)