Remove getComputedStyle calls

This commit is contained in:
Cohee 2024-07-12 16:01:20 +00:00
parent a57d994913
commit 684ce999f3
2 changed files with 4 additions and 9 deletions

View File

@ -9234,12 +9234,10 @@ jQuery(async function () {
* @param {HTMLTextAreaElement} e Textarea element to auto-fit * @param {HTMLTextAreaElement} e Textarea element to auto-fit
*/ */
function autoFitEditTextArea(e) { function autoFitEditTextArea(e) {
const computedStyle = window.getComputedStyle(e);
const maxHeight = parseInt(computedStyle.maxHeight, 10);
scroll_holder = chatElement[0].scrollTop; scroll_holder = chatElement[0].scrollTop;
e.style.height = computedStyle.minHeight; e.style.height = '0px';
const newHeight = e.scrollHeight + 4; const newHeight = e.scrollHeight + 4;
e.style.height = (newHeight < maxHeight) ? `${newHeight}px` : `${maxHeight}px`; e.style.height = `${newHeight}px`;
is_use_scroll_holder = true; is_use_scroll_holder = true;
} }
const autoFitEditTextAreaDebounced = debouncedThrottle(autoFitEditTextArea, debounce_timeout.short); const autoFitEditTextAreaDebounced = debouncedThrottle(autoFitEditTextArea, debounce_timeout.short);

View File

@ -694,16 +694,13 @@ const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
* this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height) * this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
*/ */
function autoFitSendTextArea() { function autoFitSendTextArea() {
// Needs to be pulled dynamically because it is affected by font size changes
const computedStyle = window.getComputedStyle(sendTextArea);
const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight); const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight);
if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) { if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) {
const sendTextAreaMinHeight = computedStyle.minHeight; const sendTextAreaMinHeight = '0px';
sendTextArea.style.height = sendTextAreaMinHeight; sendTextArea.style.height = sendTextAreaMinHeight;
} }
const maxHeight = parseInt(computedStyle.maxHeight, 10);
const newHeight = sendTextArea.scrollHeight + 3; const newHeight = sendTextArea.scrollHeight + 3;
sendTextArea.style.height = (newHeight < maxHeight) ? `${newHeight}px` : `${maxHeight}px`; sendTextArea.style.height = `${newHeight}px`;
if (!isFirefox) { if (!isFirefox) {
const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom)); const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom));