diff --git a/static/js/game.js b/static/js/game.js index 2f144ed..fc83a54 100644 --- a/static/js/game.js +++ b/static/js/game.js @@ -76,6 +76,7 @@ // ---------- Suche / Autocomplete ---------- let searchTimer = null; + let searchSeq = 0; let suggestions = []; let selectedIndex = -1; @@ -84,7 +85,10 @@ const q = searchInput.value.trim(); if (!q) { closeAutocomplete(); return; } searchTimer = setTimeout(async () => { + const mySeq = ++searchSeq; const res = await fetch(`/api/search?q=${encodeURIComponent(q)}`); + // Nur die aktuellste Anfrage uebernehmen (Race vermeiden) + if (mySeq !== searchSeq) return; suggestions = await res.json(); renderAutocomplete(); }, 200);