Repository navigation
fix(search): lock in SearchBar debouncing with tests, configurable delay + instant clear - #629
Merged
nonsobethel0-dev merged 2 commits intoSep 23, 2026
Conversation
Expose a debounceMs prop (default 250ms) instead of a hard-coded delay, and make the clear button reset results immediately rather than waiting out the debounce window.
Existing tests only checked static markup. Add behavioral tests proving
rapid keystrokes collapse into one onSearch call, custom debounceMs is
honoured, and clearing fires onSearch('') immediately.
|
@davidishere1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
❌ Deploy Preview for boisterous-sunshine-dd4c4c failed.
|
nonsobethel0-dev
merged commit Sep 23, 2026
ac48550
into
Parashield-Protocol:main
0 of 4 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The issue says
SearchBarcallsonSearchon every keystroke, re-filtering the product list each time. On currentmainthat's no longer the case.SearchBaralready debounces withuseDebounce(query, 250), added in 93b4375, and the homepage passes the stablesetSearchQuerysetter asonSearch, so the effect doesn't fire on unrelated renders.What was missing:
SearchBartests only check static markup, so a regression back to per-keystroke searching would pass CI.Changes
src/components/SearchBar.tsxdebounceMsprop, default250so current behaviour is unchanged. The issue suggests ~200ms; the existing 250ms is kept to avoid visible churn, and callers can now tune it.onSearch('')right away as well as resetting the input, so the full product list comes back instantly.src/__tests__/SearchBar.test.tsxNew behavioural tests using fake timers:
onSearchcalls while typing and exactly one call with the final value ('flood') once the debounce window passes.debounceMs={500}is respected.onSearch('')immediately and empties the input.Verification
npx vitest run src/__tests__/SearchBar.test.tsx: 8/8 pass (5 existing + 3 new).tsc --noEmitreports no errors in the touched files.Closes [ux] Search bar doesn't debounce input, triggers re-render on every keystroke #528
Closes [bug] useFocusTrap doesn't restore focus when modal closes #529
Closes [security] Contract RPC server singleton is never reset when URL changes #531
Closes [bug] PolicyCard shows incorrect expiry time for policies expiring in exactly 24h #530