diff --git a/l4d2web/l4d2web/static/js/console-autocomplete.js b/l4d2web/l4d2web/static/js/console-autocomplete.js index 3dd9ca0..7dc6fe4 100644 --- a/l4d2web/l4d2web/static/js/console-autocomplete.js +++ b/l4d2web/l4d2web/static/js/console-autocomplete.js @@ -93,6 +93,9 @@ function bindConsoleAutocomplete(form) { const chosen = items[highlightIdx]; const slice = firstTokenSlice(input.value, input.selectionStart || 0); if (!slice) return; + // If the first token is already exactly the chosen name, accepting it + // would be a no-op; close the dropdown so Tab feels responsive. + if (slice.token === chosen.name) { close(); return; } const before = input.value.slice(0, slice.from); const after = input.value.slice(slice.to); input.value = before + chosen.name + after; @@ -116,6 +119,9 @@ function bindConsoleAutocomplete(form) { input.addEventListener("focus", async () => { if (!vocab) { vocab = await loadVocab(); + // If the user already typed during the fetch, rank now so the + // dropdown doesn't appear to lag a keystroke behind on cold load. + if (vocab && document.activeElement === input) recompute(); } }, { once: true });