From e22b18ce809f569960d302db78a8784da6f1a440 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 11 Jul 2024 21:25:52 +0300 Subject: [PATCH] Don't overextend edit textarea height --- public/script.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index ebd911738..f6cf2dba9 100644 --- a/public/script.js +++ b/public/script.js @@ -9232,9 +9232,12 @@ jQuery(async function () { * @param {HTMLTextAreaElement} e Textarea element to auto-fit */ function autoFitEditTextArea(e) { + const computedStyle = window.getComputedStyle(e); + const maxHeight = parseInt(computedStyle.maxHeight, 10); + const newHeight = e.scrollHeight + 4; scroll_holder = chatElement[0].scrollTop; - e.style.height = '0'; - e.style.height = `${e.scrollHeight + 4}px`; + e.style.height = computedStyle.minHeight; + e.style.height = (newHeight < maxHeight) ? `${newHeight}px` : `${maxHeight}px`; is_use_scroll_holder = true; } const autoFitEditTextAreaDebounced = debouncedThrottle(autoFitEditTextArea, debounce_timeout.short);