From 09c2445ac94ddad9dfc3414c57e83d3e653cbcb1 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Fri, 26 Jun 2026 19:40:12 +0800 Subject: [PATCH] fix(ui): prevent scroll jump on model card click caused by sort dropdown focus The document-level click handler in SortDropdown.js called trigger.focus() unconditionally on every click outside the sort group. When a model card was clicked to open the modal, focus() triggered scrollIntoView on the .sort-trigger button, perturbing .page-content.scrollTop and causing the card grid to jump up a few pixels. The same interference also broke the back-to-top smooth-scroll animation: frame-by-frame focus/scroll perturbations caused VirtualScroller to schedule repeated re-renders, interrupting the compositor-thread scroll. Fix: only return focus to the trigger when the dropdown was actually open, so ordinary page clicks (e.g. clicking a model card) never force focus. --- static/js/components/controls/SortDropdown.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/js/components/controls/SortDropdown.js b/static/js/components/controls/SortDropdown.js index ab73b76d..31b15f4b 100644 --- a/static/js/components/controls/SortDropdown.js +++ b/static/js/components/controls/SortDropdown.js @@ -230,8 +230,12 @@ export function initSortDropdown(select) { // Close dropdown when clicking outside document.addEventListener('click', (event) => { if (!group.contains(event.target)) { + const wasOpen = group.classList.contains('active'); close(); - trigger.focus(); + // Only return focus to the trigger when the dropdown was actually + // open — avoids forcing scrollIntoView on every page click (which + // causes the scroll container to jump when clicking a model card). + if (wasOpen) trigger.focus(); } });