Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
math_tutor_dev
public_math_tutor
Commits
4ff58000
Commit
4ff58000
authored
Jan 21, 2026
by
Kantz
Browse files
autoscrolling
parent
ee2773fc
Changes
1
Show whitespace changes
Inline
Side-by-side
math-tutor/frontend/src/components/Chat/MessageList.tsx
View file @
4ff58000
import
{
useEffect
,
useRef
}
from
"
react
"
;
import
MessageBubble
from
"
./MessageBubble
"
;
import
MessageBubble
from
"
./MessageBubble
"
;
export
type
ChatMessage
=
{
export
type
ChatMessage
=
{
...
@@ -11,8 +12,16 @@ type MessageListProps = {
...
@@ -11,8 +12,16 @@ type MessageListProps = {
};
};
export
default
function
MessageList
({
messages
}:
MessageListProps
)
{
export
default
function
MessageList
({
messages
}:
MessageListProps
)
{
const
listRef
=
useRef
<
HTMLDivElement
|
null
>
(
null
);
useEffect
(()
=>
{
if
(
listRef
.
current
)
{
listRef
.
current
.
scrollTop
=
listRef
.
current
.
scrollHeight
;
}
},
[
messages
.
length
]);
return
(
return
(
<
div
className
=
"message-list"
>
<
div
className
=
"message-list"
ref
=
{
listRef
}
>
{
messages
.
map
((
message
)
=>
(
{
messages
.
map
((
message
)
=>
(
<
MessageBubble
<
MessageBubble
key
=
{
message
.
id
}
key
=
{
message
.
id
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment