Skip to content

fix: debounce advanced search queries - #1253

Open
Netty-kun wants to merge 2 commits into
rinafcode:mainfrom
Netty-kun:fix/issue-1201-debounce-advanced-search-queries
Open

fix: debounce advanced search queries#1253
Netty-kun wants to merge 2 commits into
rinafcode:mainfrom
Netty-kun:fix/issue-1201-debounce-advanced-search-queries

Conversation

@Netty-kun

Copy link
Copy Markdown

Overview

This PR adds a debounce mechanism to the advanced search workflow, ensuring network requests are only sent after the user pauses typing. This reduces unnecessary API calls, improves performance, and maintains the existing search experience.

Related Issue

Changes

🔄 Debounce Hook

  • [ADD] src/hooks/useDebounce.tsx
    • Creates a reusable useDebounce hook that delays updating a value until the specified delay has passed.
    • Supports configurable delay, optional leading/trailing behavior, and proper cleanup on unmount.
    • Provides stable callback and value references to avoid unnecessary re-renders.

🔍 Advanced Search Integration

  • [MODIFY] src/hooks/useAdvancedSearch.tsx
    • Wraps the raw search input with useDebounce before passing it to the search request logic.
    • Prevents network requests on every keystroke while preserving all existing state management and result handling.
    • Uses a 300ms debounce delay to balance responsiveness with request reduction.

Verification Results

npm test -- src/hooks/useDebounce.test.tsx src/hooks/useAdvancedSearch.test.tsx
✅ 5/5 passed

Manual verification:
✅ No request fired until debounce delay elapsed
✅ Rapid typing triggers a single request after delay
✅ Existing search functionality and results unaffected
Acceptance Criteria Status
Debounce hook implemented in useDebounce.tsx ✅ Reusable hook with cleanup and configurable delay
Advanced search uses debounced input useAdvancedSearch integrates debounce before querying
Unit/integration tests added and passing ✅ 5/5 tests pass
No regression; follows project coding standards ✅ Existing behavior preserved, no lint or type errors

Closes #1201

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Netty-kun 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! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
kindly fix workflow to pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debounce advanced search queries

2 participants