Firefox: restore chat scroll top on edit textarea autofit

This commit is contained in:
Cohee 2024-12-26 13:24:48 +00:00
parent e33e0b1e64
commit 0d79bb6f6d

View File

@ -9732,9 +9732,11 @@ 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 scrollTop = chatElement.scrollTop();
e.style.height = '0px'; e.style.height = '0px';
const newHeight = e.scrollHeight + 4; const newHeight = e.scrollHeight + 4;
e.style.height = `${newHeight}px`; e.style.height = `${newHeight}px`;
chatElement.scrollTop(scrollTop);
} }
const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short); const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short);
document.addEventListener('input', e => { document.addEventListener('input', e => {