Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
Loading