diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 15:15:37 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 15:15:37 +0200 |
| commit | b30150a8feb960c0667eaff6cb105dcc55b65744 (patch) | |
| tree | b953226c6dc323b2b83c2df9677460c4aa4697e6 | |
| parent | 59c840c21798d515bfc375bead87e690cd70900a (diff) | |
fix(groceries): prevent premature auto-submit on quick-add input
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.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | src/routes/+page.svelte | 12 |
2 files changed, 16 insertions, 0 deletions
@@ -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, |
