From 5cfb2d8e6de5215b91ea5dd60df291a0d070c136 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sun, 30 Nov 2025 20:58:27 +0530 Subject: [PATCH] Fix autocomp behaviour to ignore non-Kannada inputs and always select the first suggestion. --- base.html | 2 +- static/autocomp.js | 2 +- static/main.js | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/base.html b/base.html index b857d09..9d91377 100644 --- a/base.html +++ b/base.html @@ -58,7 +58,7 @@
+ type="text" id="q" name="q" value="{{ if .Data.Query }}{{ .Data.Query.Query }}{{ end }}" data-autocomp-autoselect="false" />
diff --git a/static/autocomp.js b/static/autocomp.js index a4ba4f7..d94280d 100644 --- a/static/autocomp.js +++ b/static/autocomp.js @@ -122,7 +122,7 @@ function autocomp(el, options = {}) { return; } - val = opt.onSelect(items[idx]); + val = opt.onSelect(items[idx], items); el.value = val || items[idx]; } diff --git a/static/main.js b/static/main.js index 30b6a35..1fe5e39 100644 --- a/static/main.js +++ b/static/main.js @@ -298,8 +298,12 @@ async function screenshotElement(element) { }); }, - onSelect: (val) => { - // autocomp search isn't complete. Use the user's input instead of autocomp selection. + onSelect: (val, items) => { + // If the val is English, then pick the first item from items and use that. + if (/^[A-Za-z0-9\-,'" ]+$/.test(val) && items.length > 0) { + val = items[0]; + } + if (val) { elQ.value = val; }