From f277dd9bb1a4478e62f79b7bea77d25f4b48b693 Mon Sep 17 00:00:00 2001 From: pawndev Date: Tue, 13 Oct 2026 17:20:11 +0200 Subject: [PATCH] Keep the grid's scroll position when the main screen re-renders Finishing a download (or removing a game, making labels, refreshing the library) re-renders the whole main screen, which rebuilt the scrolling .content element and sent the view back to the top. refreshMain now saves and restores the scroll of the grid and the drawer around render(). Opening a game's drawer still starts it at the top. Co-Authored-By: Claude Opus 5.5 (1M context) --- frontend/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/app.js b/frontend/app.js index 1fdf143..556caa4 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -796,11 +796,15 @@ async function eject(btn) { } } -// Re-render the main screen but keep the search box focused. +// Re-render the main screen but keep the search box focused and the grid and +// drawer scrolled where they were, so finishing a download doesn't jump to the top. +const SCROLLERS = [".content", ".drawer-body"]; function refreshMain() { if (!state.card || !state.connected || state.choosingCard) return; const focused = document.activeElement && document.activeElement.id === "search"; + const scrolled = SCROLLERS.map((sel) => { const el = document.querySelector(sel); return el ? el.scrollTop : 0; }); render(); + SCROLLERS.forEach((sel, i) => { const el = document.querySelector(sel); if (el) el.scrollTop = scrolled[i]; }); if (focused) { const s = document.getElementById("search"); s.focus(); @@ -865,6 +869,8 @@ function openDrawer(g) { state.editor = null; state.pendingShell = null; refreshMain(); + const body = document.querySelector(".drawer-body"); + if (body) body.scrollTop = 0; } function closeDrawer() { state.drawer = null;