@@ -14,7 +14,7 @@ import '../ui/hb-chip';
1414import { ThemedElement } from '../themed-element' ;
1515
1616/**
17- * A Filters button that shows the tag and complexity chips under it, and the selected filters as
17+ * A Filters button that shows the track, tag and complexity chips under it, and the selected filters
1818 * chips that remove themselves. Filters live in the URL, so they survive reloads and links.
1919 */
2020@customElement ( 'filter-menu' )
@@ -102,9 +102,22 @@ export class FilterMenu extends ThemedElement {
102102 accessor opened = false ;
103103
104104 private groupTitle ( key : FilterGroupKey ) {
105- return key === FilterGroupKey . tags
106- ? msg ( 'Tags' , { id : 'shared.filter-menu.tags' } )
107- : msg ( 'Complexity' , { id : 'shared.filter-menu.complexity' } ) ;
105+ switch ( key ) {
106+ case FilterGroupKey . tags :
107+ return msg ( 'Tags' , { id : 'shared.filter-menu.tags' } ) ;
108+ case FilterGroupKey . track :
109+ return msg ( 'Tracks' , { id : 'shared.filter-menu.tracks' } ) ;
110+ default :
111+ return msg ( 'Complexity' , { id : 'shared.filter-menu.complexity' } ) ;
112+ }
113+ }
114+
115+ // Selected filters come from the URL, which has the tag but not the label.
116+ private label ( selected : Filter ) {
117+ const filter = this . filterGroups
118+ . find ( ( group ) => group . key === selected . group )
119+ ?. filters . find ( ( item ) => generateClassName ( item . tag ) === selected . tag ) ;
120+ return filter ?. label ?? selected . tag ;
108121 }
109122
110123 private resultsLabel ( count : number ) {
@@ -140,7 +153,7 @@ export class FilterMenu extends ThemedElement {
140153 ( filter ) => html `
141154 < li >
142155 < hb-chip filter selected @click ="${ ( ) => this . toggle ( filter ) } ">
143- ${ filter . tag }
156+ ${ this . label ( filter ) }
144157 </ hb-chip >
145158 </ li >
146159 ` ,
@@ -180,7 +193,7 @@ export class FilterMenu extends ThemedElement {
180193 style ="${ styleMap ( group . key === FilterGroupKey . tags ? tagChipStyle ( filter . tag ) : { } ) } "
181194 @click ="${ ( ) => this . toggle ( filter ) } "
182195 >
183- ${ filter . tag }
196+ ${ filter . label ?? filter . tag }
184197 </ hb-chip >
185198 </ li >
186199 ` ,
0 commit comments