fix(web): topbar place Enter picks best match on /map instead of /search #1216
Loading…
Reference in a new issue
No description provided.
Delete branch "ux/topbar-place-enter-pick"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Gap
On /map, typing a place and pressing Enter faster than the 300 ms suggestion debounce left no active suggestion row, so the form fell through to the plain /search media-results page — the wrong intent on the map page.
Behaviour after this PR
On /map (place search active), Enter with no active suggestion row:
aria-expandedtrue while waiting,aria-activedescendantnull until rows exist, quiet status line only — no dialogs/toasts.Mobile expanded field is identical (same component/handler). All other pages are unchanged — the component only renders when the page registers
onPlaceSearchSelect.Implementation
TopbarPlaceSuggestions.svelte: the debounce effect now records apendingSearchentry ({ q, done, wake }) for the scheduled/in-flight run; effect cleanup wakes awaiters so a superseded search can never hang Enter. NewsettleQuery(q)awaits that entry (or runs the same seq-guarded search when the effect short-circuited on a committed query),pickBestMatch(q)settles then picksresults[0].runSearchtrackssettledQueryso Enter only ever acts on rows it owns.AppHeader.svelte: comments only, reflecting the wider Enter contract.Tests —
apps/web/tests/map-place-search.spec.ts(cold-boot gated)places/searchmocked with a 1200 ms delay so the press reliably beats the response) → map flies to Copenhagen, URL stays /map, exactly one gazetteer request, focus stays in the input, ARIA transitions checked./search?q=o(unchanged); active-row Enter picks that row (existing reopen test); click pick; existing ARIA/quiet-status coverage.Verification (apps/web)
npm run check— 0 errorsnpm run test:unit— 32 files, 239 tests passednpm run build— succeedednpx playwright test tests/map-place-search.spec.ts tests/upload-status.spec.ts— 22/22 passed twice on consecutive cold boots (preview server killed between runs)