From ccc8a2229dd82ae8d77274341785e043f6f3a343 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:59:54 -0700 Subject: [PATCH] Revert "UI: Preserve chat scroll position on textarea resize" This reverts commit 750adf793dcf1bc4c5140c84f76b932dc454c194. --- js/main.js | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) diff --git a/js/main.js b/js/main.js index 4ada64f6..4b4b14c2 100644 --- a/js/main.js +++ b/js/main.js @@ -1065,57 +1065,3 @@ document.fonts.addEventListener("loadingdone", (event) => { } }, 50); }); - -//------------------------------------------------ -// Preserve chat scroll position on textarea resize -//------------------------------------------------ -(function() { - let chatParent = null; - let initialState = null; - let debounceTimeout = null; - - function getChatParent() { - if (!chatParent) chatParent = document.querySelector(".chat-parent"); - return chatParent; - } - - function getTextarea() { - return document.querySelector("#chat-input textarea"); - } - - document.addEventListener("input", function(e) { - if (e.target.matches("#chat-input textarea")) { - const chat = getChatParent(); - const textarea = getTextarea(); - - if (chat && textarea) { - // Capture initial state only on first input of a typing sequence - if (!initialState) { - initialState = { - scrollTop: chat.scrollTop, - textareaHeight: textarea.offsetHeight - }; - } - - // Clear existing timeout - clearTimeout(debounceTimeout); - - // Wait for typing to stop (50ms delay) - debounceTimeout = setTimeout(() => { - const finalTextareaHeight = textarea.offsetHeight; - const totalGrowth = finalTextareaHeight - initialState.textareaHeight; - const targetScroll = initialState.scrollTop + totalGrowth; - - const restore = () => { chat.scrollTop = targetScroll; }; - - restore(); - requestAnimationFrame(restore); - setTimeout(restore, 0); - setTimeout(restore, 10); - - initialState = null; - }, 50); - } - } - }, true); -})();