fix(web): topbar place suggestions reopen after a pick + place-search placeholder #1207
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/topbar-place-search-refocus"
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?
Bug (user report, desktop /map)
Root cause
A pick dismisses the suggestion list (
select()setsopen = false) while the input keeps DOM focus — the option'smousedownispreventDefault()ed so focus never leaves, andhandlePlaceSelectonly refocuses an already-focused field (no focus event). The only thing that re-opened the list was thefalse→truefocus edge inTopbarPlaceSuggestions($effect(() => { if (focused) open = true; })). Since focus never left, that edge never fired again, soopenstayedfalseforever: typing showed no list, and withshowDropdownfalse, Enter was no longer consumed → plain media-search submit. Alt+Tab forced a real window blur+focus cycle, which resynced the bookkeeping — matching the user's workaround.Fix
TopbarPlaceSuggestions.svelte: a second effect re-opens the list whenever the field is focused and the query moves on from the committed pick (focused && trimmedQuery !== committedQuery). Landing exactly on the committed name right after the pick does not pop the list back open; the original focus-edge effect is kept for the blur→refocus path (existing click-away → refocus behaviour).committedQueryis now committed trimmed to matchtrimmedQuery, so a place name with stray whitespace can't read as "query moved on". Covers both selection paths (mouse click and keyboard Enter) since both go throughselect().Enhancement
When place search is active (
/map, desktop + mobile expanded field), the placeholder and sr-only label say it searches places via newheaderSearchPlaceskey:Every other page keeps "Search your library" (
headerSearchLibrary).Tests
Extended
apps/web/tests/map-place-search.spec.tswith a regression test: pick Copenhagen (mouse) → map flies → typeaarh→ Aarhus suggestion re-opens without any window refocus → pick via keyboard Enter → map flies again (URL viewport sync changes). Ran red before the fix (Aarhus list never appeared, all retries), green after. Runs on bothdesktopandmobileprojects with the suite's cold-boot hydration gates.Verified locally in
apps/web:npm run check— 0 errorsnpm run test:unit— 217/217 passednpm run build— OKnpx playwright test tests/map-place-search.spec.ts— 6/6 passed on two consecutive cold boots (preview server killed between runs)/map(placeholder + sr-only) and/search(unchanged media wording)