Auto-resize input field after a message was sent

This commit is contained in:
Julian Müller (ChaoticByte) 2023-04-30 19:34:11 +02:00
parent cbdccf3b92
commit bfb8b6baf2

View file

@ -111,6 +111,13 @@
messageHistoryContainer.scrollTo(0, messageHistoryContainer.scrollHeight);
}
function resizeInputElement() {
// Calculate Line height
textInputElement.style.removeProperty("height");
let newHeight = textInputElement.scrollHeight;
textInputElement.style.height = newHeight.toString() + "px";
}
function disableInput() {
settingsMaxTokensElement.disabled = true;
settingsTemperatureElement.disabled = true;
@ -145,6 +152,7 @@
}
else {
textInputElement.value = "";
resizeInputElement();
addMessage(input, MessageType.USER);
let prompt = conversation.join("");
let settings = getSettings();
@ -174,11 +182,6 @@
}
});
textInputElement.addEventListener("input", e => {
// Calculate Line height
textInputElement.style.removeProperty("height");
let newHeight = textInputElement.scrollHeight;
textInputElement.style.height = newHeight.toString() + "px";
});
textInputElement.addEventListener("input", resizeInputElement);
})();