fix(search): prevent stale navigation from clobbering focused search input #41

Merged
marcel merged 1 commits from fix/34-url-synced-input-keystroke-loss into main 2026-03-20 21:06:28 +01:00
Owner

Closes #34

Summary

  • Add qFocused flag (set via onfocus/onblur) to the full-text search input on /
  • Guard the q assignment in the sync $effect so it only runs while the input is not focused
  • Add a regression test that rerenders the component with stale data.filters.q while the input is focused and asserts the typed value is preserved

Root cause

The $effect that syncs URL params → local state ran unconditionally on every navigation. Fast typing triggered a goto() debounce; when the first navigation completed, the effect immediately overwrote the still-focused input with the stale URL value — dropping every character typed during the in-flight request.

Test plan

  • npm run test — all 5 client test files pass, including the new keystroke-preservation test
  • npm run lint && npm run check — no errors
  • Manual: type quickly in the document search on / — no dropped characters or flicker
Closes #34 ## Summary - Add `qFocused` flag (set via `onfocus`/`onblur`) to the full-text search input on `/` - Guard the `q` assignment in the sync `$effect` so it only runs while the input is **not** focused - Add a regression test that rerenders the component with stale `data.filters.q` while the input is focused and asserts the typed value is preserved ## Root cause The `$effect` that syncs URL params → local state ran unconditionally on every navigation. Fast typing triggered a `goto()` debounce; when the first navigation completed, the effect immediately overwrote the still-focused input with the stale URL value — dropping every character typed during the in-flight request. ## Test plan - [ ] `npm run test` — all 5 client test files pass, including the new keystroke-preservation test - [ ] `npm run lint && npm run check` — no errors - [ ] Manual: type quickly in the document search on `/` — no dropped characters or flicker
marcel added 1 commit 2026-03-20 20:58:38 +01:00
fix(search): prevent stale navigation from clobbering focused search input
Some checks failed
CI / E2E Tests (push) Waiting to run
CI / Unit & Component Tests (push) Successful in 10m14s
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (pull_request) Failing after 13m49s
CI / Backend Unit Tests (pull_request) Failing after 13m59s
CI / Unit & Component Tests (pull_request) Failing after 14m9s
acf6fc05ad
The sync $effect on the home page unconditionally overwrote the local `q`
state with the URL value after every navigation. When users typed faster
than a navigation round-trip (debounce fires → goto() → data reloads),
the completed navigation wrote the stale URL value back into the input,
dropping the characters typed in the interim.

Guard the `q` assignment in the effect with a `qFocused` flag (set via
onfocus/onblur on the text input). Covers issue #34.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel merged commit acf6fc05ad into main 2026-03-20 21:06:28 +01:00
marcel deleted branch fix/34-url-synced-input-keystroke-loss 2026-03-20 21:06:33 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#41