fix: scroll to the top of a chat on the first click of Scroll to Top (#28659)

This commit is contained in:
G30 authored and GitHub committed 2026-08-17 00:40:14 -06:00
1 parent 16f118d77a
commit ad72dc6658
1 file changed
+11 -6
+11 -6
View File
@@ -159,12 +159,17 @@
messagesCount = null; messagesCount = null;
buildMessages(); buildMessages();
await tick(); await tick();
if (messages.length > 0) {
const firstMessageEl = document.getElementById(`message-${messages[0].id}`); const element = getMessagesContainer();
if (firstMessageEl) { if (!element) return;
firstMessageEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
} element.scrollTo({ top: 0, behavior: 'smooth' });
} requestAnimationFrame(() => {
element.scrollTo({ top: 0, behavior: 'smooth' });
requestAnimationFrame(() => {
element.scrollTo({ top: 0, behavior: 'smooth' });
});
});
}; };
const updateChat = async () => { const updateChat = async () => {