From a429e6b1c3f18c9b2935a3f2f0128bd33e59219f Mon Sep 17 00:00:00 2001 From: Will Miao Date: Fri, 26 Jun 2026 16:31:31 +0800 Subject: [PATCH] fix(ui): replace smooth scroll with instant for back-to-top to avoid VirtualScroller conflict The back-to-top button used scrollTo({top:0, behavior:'smooth'}) which conflicts with VirtualScroller's DOM manipulations during the smooth scroll animation. Each animation frame triggered handleScroll() -> scheduleRender() -> renderItems(), causing the browser to interrupt the smooth scroll animation mid-way, resulting in only ~1 page of upward scroll instead of reaching the top. Root cause: commit 311e89e9 fixed VirtualScroller to listen on the correct scroll container (.page-content), but this meant every scroll event during smooth animation now triggers expensive DOM operations that abort the browser's compositor-thread smooth scroll animation. Fix: use instant scroll (scrollTop = 0) so the position is set immediately without triggering frame-by-frame VirtualScroller interference. --- static/js/utils/uiHelpers.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/static/js/utils/uiHelpers.js b/static/js/utils/uiHelpers.js index 961d1042..09e231d3 100644 --- a/static/js/utils/uiHelpers.js +++ b/static/js/utils/uiHelpers.js @@ -384,12 +384,9 @@ export function initBackToTop() { } }; - // Smooth scroll to top + // Scroll to top button.addEventListener('click', () => { - scrollContainer.scrollTo({ - top: 0, - behavior: 'smooth' - }); + scrollContainer.scrollTop = 0; }); // Listen for scroll events on the scrollable container