From e98d8c5717f63517c08c1145ae209adedadc82bd Mon Sep 17 00:00:00 2001 From: Ponte Date: Thu, 5 Mar 2026 19:25:48 +0100 Subject: [PATCH] Fix: prevent scroll jump while editing game fields --- app.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 43d20f6..c4a683e 100644 --- a/app.js +++ b/app.js @@ -100,6 +100,7 @@ let scannerRunning = false; let scannerLoopId = null; let scannerLastCodeValue = ""; let scannerLastCodeAt = 0; +let resizeRenderTimeout = null; let selectedGameIds = new Set(); let currentPage = 1; let currentPageGameIds = []; @@ -290,7 +291,27 @@ if (nextPageBtn) { } window.addEventListener("resize", () => { - renderGames(); + // Mobile virtual keyboards trigger resize events. Avoid rerendering while editing, + // otherwise the list rebuild can jump to top and break inline input edits. + if (inlineEditingGameId || editingGameId) { + return; + } + + const active = document.activeElement; + if ( + active instanceof HTMLInputElement || + active instanceof HTMLTextAreaElement || + active instanceof HTMLSelectElement + ) { + return; + } + + if (resizeRenderTimeout) { + clearTimeout(resizeRenderTimeout); + } + resizeRenderTimeout = window.setTimeout(() => { + renderGames(); + }, 120); }); if (v2SearchInput) {