From e6efccc3d1a50aa286b32e171f0f64d4d9072457 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Mon, 15 Sep 2025 08:45:42 +0200 Subject: [PATCH] feat: sort tags in KanbanFilters by usage count - Added sorting functionality to `KanbanFilters` to display tags in descending order based on their usage count. - Introduced `sortedTags` using `useMemo` for performance optimization, ensuring efficient re-calculation when `availableTags` or `tagCounts` change. - Updated the rendering logic to utilize `sortedTags` instead of `availableTags`, enhancing the user experience by prioritizing frequently used tags. --- components/kanban/KanbanFilters.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/kanban/KanbanFilters.tsx b/components/kanban/KanbanFilters.tsx index a1a932b..157b658 100644 --- a/components/kanban/KanbanFilters.tsx +++ b/components/kanban/KanbanFilters.tsx @@ -138,6 +138,15 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) count: priorityCounts[priorityConfig.key] || 0 })); + // Trier les tags par nombre d'utilisation (décroissant) + const sortedTags = useMemo(() => { + return [...availableTags].sort((a, b) => { + const countA = tagCounts[a.name] || 0; + const countB = tagCounts[b.name] || 0; + return countB - countA; // Décroissant + }); + }, [availableTags, tagCounts]); + return (
@@ -302,7 +311,7 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) Tags
- {availableTags.map((tag) => ( + {sortedTags.map((tag) => (