fix: scroll to the top of a chat on the first click of Scroll to Top (#28659)
This commit is contained in:
1 file changed
+11
-6
@@ -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 () => {
|
||||||
|
|||||||
Reference in new issue
Block a user