fix(web): topbar place suggestions reopen after a pick + place-search placeholder #1207

Merged
chris merged 4 commits from fix/topbar-place-search-refocus into main 2026-10-14 00:57:55 +02:00
Owner

Bug (user report, desktop /map)

  1. Type a place in the topbar, pick a suggestion → map flies. ✔
  2. Type a different place → no suggestions; Enter falls through to /search.
  3. Alt+Tab out of the browser and back → works again.

Root cause

A pick dismisses the suggestion list (select() sets open = false) while the input keeps DOM focus — the option's mousedown is preventDefault()ed so focus never leaves, and handlePlaceSelect only refocuses an already-focused field (no focus event). The only thing that re-opened the list was the false→true focus edge in TopbarPlaceSuggestions ($effect(() => { if (focused) open = true; })). Since focus never left, that edge never fired again, so open stayed false forever: typing showed no list, and with showDropdown false, 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). committedQuery is now committed trimmed to match trimmedQuery, 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 through select().

Enhancement

When place search is active (/map, desktop + mobile expanded field), the placeholder and sr-only label say it searches places via new headerSearchPlaces key:

Locale Wording
EN Search places
DE Nach Orten suchen
DA Søg efter steder

Every other page keeps "Search your library" (headerSearchLibrary).

Tests

Extended apps/web/tests/map-place-search.spec.ts with a regression test: pick Copenhagen (mouse) → map flies → type aarh → 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 both desktop and mobile projects with the suite's cold-boot hydration gates.

Verified locally in apps/web:

  • npm run check — 0 errors
  • npm run test:unit — 217/217 passed
  • npm run build — OK
  • npx playwright test tests/map-place-search.spec.ts — 6/6 passed on two consecutive cold boots (preview server killed between runs)
  • Runtime smoke of the placeholder in all three locales on /map (placeholder + sr-only) and /search (unchanged media wording)
## Bug (user report, desktop /map) 1. Type a place in the topbar, pick a suggestion → map flies. ✔ 2. Type a *different* place → no suggestions; Enter falls through to /search. 3. Alt+Tab out of the browser and back → works again. ### Root cause A pick dismisses the suggestion list (`select()` sets `open = false`) while the input **keeps DOM focus** — the option's `mousedown` is `preventDefault()`ed so focus never leaves, and `handlePlaceSelect` only refocuses an already-focused field (no focus event). The only thing that re-opened the list was the `false→true` focus edge in `TopbarPlaceSuggestions` (`$effect(() => { if (focused) open = true; })`). Since focus never left, that edge never fired again, so `open` stayed `false` forever: typing showed no list, and with `showDropdown` false, 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). `committedQuery` is now committed trimmed to match `trimmedQuery`, 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 through `select()`. ## Enhancement When place search is active (`/map`, desktop + mobile expanded field), the placeholder and sr-only label say it searches places via new `headerSearchPlaces` key: | Locale | Wording | | --- | --- | | EN | Search places | | DE | Nach Orten suchen | | DA | Søg efter steder | Every other page keeps "Search your library" (`headerSearchLibrary`). ## Tests Extended `apps/web/tests/map-place-search.spec.ts` with a regression test: pick Copenhagen (mouse) → map flies → type `aarh` → 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 both `desktop` and `mobile` projects with the suite's cold-boot hydration gates. Verified locally in `apps/web`: - `npm run check` — 0 errors - `npm run test:unit` — 217/217 passed - `npm run build` — OK - `npx playwright test tests/map-place-search.spec.ts` — 6/6 passed on two consecutive cold boots (preview server killed between runs) - Runtime smoke of the placeholder in all three locales on `/map` (placeholder + sr-only) and `/search` (unchanged media wording)
fix(web): re-open topbar place suggestions after a pick; place-search placeholder
Some checks failed
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 6s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 17m15s
8ddf87f52d
A pick dismissed the suggestions list while the input kept DOM focus (the
option mousedown is prevented, and the header refocuses the field
programmatically), so the false->true focus edge that re-opens the list
never fired again: the next query showed no suggestions and Enter fell
through to /search until a real window blur+focus cycle resynced the
state. Any query that moves on from the committed pick now re-opens the
list while the field is focused; the refocus edge is kept for the
blur->focus path.

Also label the field as a place search on /map (EN 'Search places', DE
'Nach Orten suchen', DA 'Søg efter steder', new headerSearchPlaces
message); every other page keeps 'Search your library'. Covers desktop
and the mobile expanded field.

Regression test: pick (mouse) -> type a new query -> suggestions re-open
-> pick (keyboard Enter) -> map flies again, on both viewport projects.
docs(known-issues): record upload-status.spec.ts:269 CI flake (run 4682)
Some checks failed
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 11m3s
ccc7ec0953
Merge remote-tracking branch 'origin/main' into fix/topbar-place-search-refocus
Some checks failed
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 2s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 20m22s
8f56f043d9
test(web): gate upload-status file inputs on hydration (ISSUE-154)
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 2s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 7m59s
417187e3e5
The three file-input tests (uploads a mixed batch / auto-starts folder
upload / continues adding received files) fire setInputsFiles or dispatch
a change event immediately after page.goto. goto resolves on the load
event, which can precede SvelteKit hydration, so the file inputs'
on:change handlers may not be attached yet: the event is silently
dropped, files stays empty, and the 'Upload selected files' button
(disabled while files.length === 0) never enables. On :269 that times out
at 90s (terminal); :52/:131 fail an upstream assert then pass on retry.
Deterministic mechanism, load-triggered — it loses on a cold preview
server under a queued CI runner and wins on a warm box.

Not an i18n break: EN copy uploadReadyCount/uploadSummaryLine is intact
and PR#1202 touched no uploads files.

Gate each test on a client-boot signal before interacting: AppShell
fetches the processing summary in onMount on every route, so the first
summary request proves handlers are attached. gotoUploadsHydrated helper
covers :52/:269; :131 polls its own existing summary counter. No sleeps.
chris merged commit f0f847518a into main 2026-10-14 00:57:55 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1207
No description provided.