CSS: don't change --chat-height when outside the chat tab

This commit is contained in:
oobabooga 2023-12-27 11:51:55 -08:00
parent c419206ce1
commit a4079e879e

View File

@ -339,6 +339,7 @@ function updateCssProperties() {
// Set the height of the chat area // Set the height of the chat area
const chatContainer = document.getElementById("chat").parentNode.parentNode.parentNode; const chatContainer = document.getElementById("chat").parentNode.parentNode.parentNode;
const chatInputHeight = document.querySelector("#chat-input textarea").clientHeight; const chatInputHeight = document.querySelector("#chat-input textarea").clientHeight;
if (chatContainer.clientHeight > 0) {
const newChatHeight = `${chatContainer.clientHeight - chatInputHeight + 40}px`; const newChatHeight = `${chatContainer.clientHeight - chatInputHeight + 40}px`;
document.documentElement.style.setProperty("--chat-height", newChatHeight); document.documentElement.style.setProperty("--chat-height", newChatHeight);
document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`); document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`);
@ -354,6 +355,7 @@ function updateCssProperties() {
currentChatInputHeight = chatInputHeight; currentChatInputHeight = chatInputHeight;
} }
} }
}
new ResizeObserver(updateCssProperties) new ResizeObserver(updateCssProperties)
.observe(document.querySelector("#chat-input textarea")); .observe(document.querySelector("#chat-input textarea"));