From b30150a8feb960c0667eaff6cb105dcc55b65744 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sat, 1 Aug 2026 15:15:37 +0200 Subject: fix(groceries): prevent premature auto-submit on quick-add input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typing 'sel régénérant' would auto-submit 'sel' because oninput fired on every keystroke, and trim() collapsed the partial input to a catalog match. Moved auto-submit to oninput with insertReplacementText guard (datalist selection) plus onchange (blur/Enter), so regular typing is never interrupted. --- README.md | 4 ++++ src/routes/+page.svelte | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 2ec894c..8a547ce 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ worker precaches assets; works offline after first visit. ### Bugs / Polish +- [x] When I type "sel régénérant", i'm interrupted at the l, it seems to auto submit "sel" + ### Features - [ ] Live updates from server @@ -71,6 +73,8 @@ worker precaches assets; works offline after first visit. ## Deploy +- [ ] Deploy bare build + node systemctl service + ```bash docker build -t home-sveltekit . docker save home-sveltekit | gzip | pv | ssh ubuntu@feed.kagamino.dev "gunzip | sudo docker load" diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 6611bbc..9900bb3 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -94,6 +94,18 @@ } }} oninput={(e) => { + if ((e as InputEvent).inputType === 'insertReplacementText') { + const val = e.currentTarget.value.trim().toLowerCase(); + const match = data.catalog.find( + (item) => item.name.toLowerCase() === val, + ); + if (match) { + name = match.name; + handleAdd(false); + } + } + }} + onchange={(e) => { const val = e.currentTarget.value.trim().toLowerCase(); const match = data.catalog.find( (item) => item.name.toLowerCase() === val, -- cgit v1.3