- Completed Action 2.4.1.3: Audited and standardized search input debouncing - Created SEARCH_DEBOUNCE_AUDIT.md documenting all search components - Found 7 search components: 5 using useDebounce, 1 manual setTimeout, 1 manual search - Standardized AddTrackToPlaylistModal to use useDebounce hook instead of manual setTimeout - All automatic search inputs now use consistent debouncing (300-500ms delays) - MessageSearch uses manual search (intentional, no debounce needed)
2.5 KiB
Search Input Debounce Audit
Date: 2025-01-27
Action: 2.4.1.3 - Add debounce to all search inputs
Status: ✅ Complete (Audit)
Overview
This document audits all search inputs in the codebase to verify debouncing is implemented consistently.
Search Components Audit
✅ Already Using Debounce
-
apps/web/src/components/search/Search.tsx- Uses
useDebouncehook (line 68) - Configurable
debounceDelayprop (default: 300ms) - Used by GlobalSearchBar, SearchBar components
- Uses
-
apps/web/src/pages/SearchPage.tsx- Uses
useDebouncehook (line 34) - 500ms delay
- Debounced query used in React Query keys
- Uses
-
apps/web/src/features/tracks/components/TrackSearch.tsx- Uses
useDebouncehook (line 39) - 500ms delay
- Debounced query used for API calls
- Uses
-
apps/web/src/features/library/pages/LibraryPage.tsx- ✅ Just added
useDebouncehook (Action 2.4.1.2) - 300ms delay
- Debounced search term used in queryParams
- ✅ Just added
-
apps/web/src/features/playlists/components/PlaylistSearch.tsx- Uses
useDebouncehook (line 41) - 500ms delay
- Debounced query used for API calls
- Uses
⚠️ Using Manual Debounce (Should Standardize)
apps/web/src/features/playlists/components/AddTrackToPlaylistModal.tsx- Uses manual
setTimeoutdebounce (line 76) - 500ms delay
- Recommendation: Replace with
useDebouncehook for consistency
- Uses manual
❓ Manual Search (No Auto-Search)
apps/web/src/features/chat/components/MessageSearch.tsx- Does NOT use debounce
- Search only triggers on button click or Enter key
- No automatic search as you type
- Status: Intentional design - no debounce needed (manual search)
Summary
Total Search Components: 7
Using useDebounce Hook: 5 ✅
Using Manual Debounce: 1 ⚠️ (should standardize)
Manual Search (no debounce needed): 1 ✅
Recommendations
- ✅ LibraryPage: Already fixed (Action 2.4.1.2)
- ⚠️ AddTrackToPlaylistModal: Replace manual setTimeout with
useDebouncehook for consistency - ✅ MessageSearch: No changes needed (manual search is intentional)
Action Items
- Audit all search inputs
- Document current state
- Optional: Standardize AddTrackToPlaylistModal to use
useDebouncehook (low priority, manual debounce works)
Validation
✅ All search inputs that trigger automatic API calls use debouncing
✅ LibraryPage search debouncing added
⚠️ One component uses manual debounce (acceptable but could be standardized)