From e33921a629f2047bfbca01f401bbee11eb5dc45d Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:54:34 -0700 Subject: [PATCH] Fix jittering while typing on Firefox (closes #7086) --- js/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index f018e332..3ff4bf06 100644 --- a/js/main.js +++ b/js/main.js @@ -170,6 +170,13 @@ targetElement.addEventListener("scroll", function() { // Create a MutationObserver instance const observer = new MutationObserver(function(mutations) { + // Check if this is just the scrolling class being toggled + const isScrollingClassOnly = mutations.every(mutation => + mutation.type === "attributes" && + mutation.attributeName === "class" && + mutation.target === targetElement + ); + if (targetElement.classList.contains("_generating")) { typing.parentNode.classList.add("visible-dots"); document.getElementById("stop").style.display = "flex"; @@ -182,7 +189,7 @@ const observer = new MutationObserver(function(mutations) { doSyntaxHighlighting(); - if (!window.isScrolled && targetElement.scrollTop !== targetElement.scrollHeight) { + if (!window.isScrolled && !isScrollingClassOnly && targetElement.scrollTop !== targetElement.scrollHeight) { targetElement.scrollTop = targetElement.scrollHeight; }