From 75fe82f0de8758eabdf835e3fc9d84f8b1c061f2 Mon Sep 17 00:00:00 2001 From: Garret Patti Date: Wed, 25 Mar 2026 18:41:37 -0400 Subject: [PATCH] group selected tags by category in TagSelector Assigned tags now render as a single outer pill per category containing smaller inner tag pills, instead of one pill per tag with a repeated category prefix. Co-Authored-By: Claude Sonnet 4.6 --- src/components/tags/TagSelector.tsx | 61 ++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/src/components/tags/TagSelector.tsx b/src/components/tags/TagSelector.tsx index b6b58ca..3fd3771 100644 --- a/src/components/tags/TagSelector.tsx +++ b/src/components/tags/TagSelector.tsx @@ -87,17 +87,60 @@ export default function TagSelector({ mediaKey }: Props) { return (
- {/* Assigned tags */} + {/* Assigned tags grouped by category */} {assigned.tags.length > 0 && (
- {assigned.tags.map((tag) => ( - toggleTag(tag)} - /> - ))} + {(() => { + const groups = new Map() + const ungrouped: Tag[] = [] + for (const tag of assigned.tags) { + if (tag.categoryId) { + const arr = groups.get(tag.categoryId) ?? [] + arr.push(tag) + groups.set(tag.categoryId, arr) + } else { + ungrouped.push(tag) + } + } + return ( + <> + {Array.from(groups.entries()).map(([catId, tags]) => { + const cat = assignedCategoryMap[catId] + return ( + + {cat?.name}: + {tags.map((tag) => ( + + {tag.name} + + + ))} + + ) + })} + {ungrouped.map((tag) => ( + toggleTag(tag)} /> + ))} + + ) + })()}
)}