From a4079e879e6a3f5ef2f9ab24475b357542aba373 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:51:55 -0800 Subject: [PATCH] CSS: don't change --chat-height when outside the chat tab --- js/main.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/js/main.js b/js/main.js index dd57dde3..59c70c73 100644 --- a/js/main.js +++ b/js/main.js @@ -339,19 +339,21 @@ function updateCssProperties() { // Set the height of the chat area const chatContainer = document.getElementById("chat").parentNode.parentNode.parentNode; const chatInputHeight = document.querySelector("#chat-input textarea").clientHeight; - const newChatHeight = `${chatContainer.clientHeight - chatInputHeight + 40}px`; - document.documentElement.style.setProperty("--chat-height", newChatHeight); - document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`); + if (chatContainer.clientHeight > 0) { + const newChatHeight = `${chatContainer.clientHeight - chatInputHeight + 40}px`; + document.documentElement.style.setProperty("--chat-height", newChatHeight); + document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`); - // Set the position offset of the chat input box - const header = document.querySelector(".header_bar"); - const headerHeight = `${header.clientHeight}px`; - document.documentElement.style.setProperty("--header-height", headerHeight); + // Set the position offset of the chat input box + const header = document.querySelector(".header_bar"); + const headerHeight = `${header.clientHeight}px`; + document.documentElement.style.setProperty("--header-height", headerHeight); - // Offset the scroll position of the chat area - if (chatInputHeight !== currentChatInputHeight) { - chatContainer.scrollTop += chatInputHeight > currentChatInputHeight ? chatInputHeight : -chatInputHeight; - currentChatInputHeight = chatInputHeight; + // Offset the scroll position of the chat area + if (chatInputHeight !== currentChatInputHeight) { + chatContainer.scrollTop += chatInputHeight > currentChatInputHeight ? chatInputHeight : -chatInputHeight; + currentChatInputHeight = chatInputHeight; + } } }