Skip to content

Commit 09c30ad

Browse files
committed
fix: Improve search box user experience in replay history
- Fixed clunky search behavior where input lost focus after each character - Added debouncing to search input (300ms delay) to prevent excessive API calls - Updated state management to use debounced search term for API calls - Improved page reset logic to work with debounced search - Enhanced user experience with smooth, continuous typing in search field - Reduced server load with fewer API requests during typing - Updated CHANGELOG.md with comprehensive fix documentation This resolves the issue where users had to click the search box again after typing each character, making search much more user-friendly.
1 parent 8c23f88 commit 09c30ad

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Enhanced error logging to show all attempted paths for better debugging
1515
- Improved fallback version handling for container environments
1616

17+
- **Search Input Focus Issue**: Fixed clunky search behavior in replay history
18+
- Added debouncing to search input to prevent excessive API calls
19+
- Fixed search box losing focus after each character typed
20+
- Improved user experience with smooth, continuous typing in search field
21+
- Search now waits 300ms after user stops typing before triggering API call
22+
1723
### Technical Improvements
1824
- VERSION file now properly copied into Docker container at `/app/VERSION`
1925
- Version endpoint tries Docker-specific paths first for better container compatibility
2026
- Enhanced logging provides better visibility into version file resolution process
2127
- Robust fallback ensures version display even if file reading fails
28+
- Debounced search reduces server load and improves frontend responsiveness
29+
- Better state management prevents unnecessary component re-renders during search
2230

2331
## [1.2.0] - 2025-07-29
2432

frontend/src/components/ReplayHistory.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useCallback } from 'react';
22
import {
33
Box,
44
Card,
@@ -44,12 +44,22 @@ const ReplayHistory = ({ onReplayStart }) => {
4444
const [replayingId, setReplayingId] = useState(null);
4545
const [filterStatus, setFilterStatus] = useState('ALL');
4646
const [searchTerm, setSearchTerm] = useState('');
47+
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState('');
4748

4849
// Pagination state
4950
const [currentPage, setCurrentPage] = useState(1);
5051
const [totalCount, setTotalCount] = useState(0);
5152
const itemsPerPage = 20;
5253

54+
// Debounce search term to avoid excessive API calls
55+
useEffect(() => {
56+
const timer = setTimeout(() => {
57+
setDebouncedSearchTerm(searchTerm);
58+
}, 300); // 300ms delay
59+
60+
return () => clearTimeout(timer);
61+
}, [searchTerm]);
62+
5363
const loadHistory = React.useCallback(async () => {
5464
try {
5565
setLoading(true);
@@ -58,7 +68,7 @@ const ReplayHistory = ({ onReplayStart }) => {
5868
const response = await apiService.getReplayHistory(
5969
itemsPerPage,
6070
offset,
61-
searchTerm,
71+
debouncedSearchTerm,
6272
filterStatus
6373
);
6474

@@ -70,7 +80,7 @@ const ReplayHistory = ({ onReplayStart }) => {
7080
} finally {
7181
setLoading(false);
7282
}
73-
}, [currentPage, itemsPerPage, searchTerm, filterStatus]);
83+
}, [currentPage, itemsPerPage, debouncedSearchTerm, filterStatus]);
7484

7585
useEffect(() => {
7686
loadHistory();
@@ -81,7 +91,7 @@ const ReplayHistory = ({ onReplayStart }) => {
8191
if (currentPage !== 1) {
8292
setCurrentPage(1);
8393
}
84-
}, [filterStatus, searchTerm, currentPage]);
94+
}, [filterStatus, debouncedSearchTerm, currentPage]);
8595

8696
const handleReplayAgain = async (historyItem) => {
8797
try {

0 commit comments

Comments
 (0)