From b2391b058ba46f807d1ba64f92f4d666adb3abdf Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 16 Jan 2025 17:19:01 -0800 Subject: [PATCH] fix --- static/js/components/chat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/js/components/chat.js b/static/js/components/chat.js index 2122064..ad876ad 100644 --- a/static/js/components/chat.js +++ b/static/js/components/chat.js @@ -9,9 +9,10 @@ const runChat = async () => { const { scrollTop, scrollHeight, clientTop } = document.getElementById( "chat-container", ) ?? { scrollTop: 0, scrollHeight: 0, clientTop: 0}; - const scrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop; + const scrollTopMax = scrollHeight - clientTop; const isAtEdge = scrollTop > (0.92 * scrollTopMax) || scrollTop === 0; document.getElementById("messages").innerHTML = html; + if (!document.getElementById("chat-container")) return; const emplacedScrollTopMax = document.getElementById("chat-container").scrollHeight - document.getElementById("chat-container").clientTop; if (isAtEdge) { document.getElementById("chat-container").scrollTop = scrollTopMax;