fix: improve local search synchronization in KanbanFilters
- Added a ref to track user typing state to prevent overwriting local search when filters change externally. - Ensured local search updates only occur when the user is not actively typing, enhancing user experience and reducing unnecessary updates.
This commit is contained in:
@@ -90,13 +90,20 @@ export function KanbanFilters({ filters, onFiltersChange, hiddenStatuses: propsH
|
||||
}, [filters, onFiltersChange]);
|
||||
|
||||
const handleSearchChange = (search: string) => {
|
||||
isUserTypingRef.current = true;
|
||||
setLocalSearch(search);
|
||||
debouncedSearchChange(search);
|
||||
};
|
||||
|
||||
// Synchroniser l'état local quand les filtres changent de l'extérieur
|
||||
// mais seulement si ce n'est pas dû à notre propre saisie
|
||||
const isUserTypingRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
setLocalSearch(filters.search || '');
|
||||
if (!isUserTypingRef.current) {
|
||||
setLocalSearch(filters.search || '');
|
||||
}
|
||||
isUserTypingRef.current = false;
|
||||
}, [filters.search]);
|
||||
|
||||
// Nettoyer le timeout au démontage
|
||||
|
||||
Reference in New Issue
Block a user