@@ -81,6 +81,8 @@ export function PromptFilters({ categories, tags, currentFilters, aiSearchEnable
8181 router . push ( "/prompts" ) ;
8282 } ;
8383
84+ const selectedTags = currentFilters . tag ? currentFilters . tag . split ( "," ) . filter ( Boolean ) : [ ] ;
85+
8486 const hasFilters = currentFilters . q || currentFilters . type || currentFilters . category || currentFilters . tag || currentFilters . sort ;
8587
8688 const activeFilterCount = [ currentFilters . type , currentFilters . category , currentFilters . tag , currentFilters . sort && currentFilters . sort !== "newest" ] . filter ( Boolean ) . length ;
@@ -318,25 +320,34 @@ export function PromptFilters({ categories, tags, currentFilters, aiSearchEnable
318320 />
319321 </ div >
320322 < div className = "flex flex-wrap gap-1 max-h-48 overflow-y-auto" >
321- { filteredTags . filter ( ( tag ) => tag . id && tag . slug ) . map ( ( tag ) => (
322- < button
323- key = { tag . id }
324- className = "px-2 py-0.5 text-[11px] rounded border transition-colors"
325- style = {
326- currentFilters . tag === tag . slug
327- ? { backgroundColor : tag . color , color : "white" , borderColor : tag . color }
328- : { borderColor : tag . color + "40" , color : tag . color }
329- }
330- onClick = { ( ) => {
331- if ( currentFilters . tag !== tag . slug ) {
332- analyticsSearch . filter ( "tag" , tag . slug ) ;
323+ { filteredTags . filter ( ( tag ) => tag . id && tag . slug ) . map ( ( tag ) => {
324+ const isSelected = selectedTags . includes ( tag . slug ) ;
325+ return (
326+ < button
327+ key = { tag . id }
328+ className = "px-2 py-0.5 text-[11px] rounded border transition-colors"
329+ style = {
330+ isSelected
331+ ? { backgroundColor : tag . color , color : "white" , borderColor : tag . color }
332+ : { borderColor : tag . color + "40" , color : tag . color }
333333 }
334- updateFilter ( "tag" , currentFilters . tag === tag . slug ? null : tag . slug ) ;
335- } }
336- >
337- { tag . name }
338- </ button >
339- ) ) }
334+ onClick = { ( ) => {
335+ let newTags : string [ ] ;
336+ if ( isSelected ) {
337+ // Remove tag
338+ newTags = selectedTags . filter ( t => t !== tag . slug ) ;
339+ } else {
340+ // Add tag
341+ newTags = [ ...selectedTags , tag . slug ] ;
342+ analyticsSearch . filter ( "tag" , tag . slug ) ;
343+ }
344+ updateFilter ( "tag" , newTags . length > 0 ? newTags . join ( "," ) : null ) ;
345+ } }
346+ >
347+ { tag . name }
348+ </ button >
349+ ) ;
350+ } ) }
340351 { filteredTags . length === 0 && tagSearch && (
341352 < span className = "text-xs text-muted-foreground" > { t ( "search.noResults" ) } </ span >
342353 ) }
0 commit comments