@@ -198,30 +198,57 @@ func (f *filterableGroupList[T]) Filter(query string) tea.Cmd {
199 var newGroups []Group[T]
199 var newGroups []Group[T]
200 for _, g := range f.groups {
200 for _, g := range f.groups {
201− words := make([]string, len(g.Items))
201+ // Check if group name matches the query
202− for i, item := range g.Items {
202+ // Extract the group name from the section - we'll use the section's view content
203+ // as a fallback since ItemSection doesn't implement FilterableItem
204+ var groupName string
205+ if section, ok := g.Section.(*itemSectionModel); ok {
206+ groupName = strings.ToLower(section.title)
208+ // Fallback to using the section's ID or view content
203− words[i] = strings.ToLower(item.FilterValue())
209+ groupName = strings.ToLower(g.Section.ID())
206− matches := fuzzy.Find(query, words)
211+ groupMatches := fuzzy.Find(query, []string{groupName})
208− sort.SliceStable(matches, func(i, j int) bool {
213+ if len(groupMatches) > 0 && groupMatches[0].Score > 0 {
209− return matches[i].Score > matches[j].Score
214+ // If group name matches, include all items from this group
210− })
215+ // Clear any existing match indexes for items since the group matched
212− var matchedItems []T
213− for _, match := range matches {
216+ for _, item := range g.Items {
214− item := g.Items[match.Index]
215− if i, ok := any(item).(HasMatchIndexes); ok {
217+ if i, ok := any(item).(HasMatchIndexes); ok {
216− i.MatchIndexes(match.MatchedIndexes)
218+ i.MatchIndexes(make([]int, 0))
218− matchedItems = append(matchedItems, item)
220− if len(matchedItems) > 0 {
221 newGroups = append(newGroups, Group[T]{
221 newGroups = append(newGroups, Group[T]{
222 Section: g.Section,
222 Section: g.Section,
223− Items: matchedItems,
223+ Items: g.Items,
226+ // Group name doesn't match, check individual items
227+ words := make([]string, len(g.Items))
228+ for i, item := range g.Items {
229+ words[i] = strings.ToLower(item.FilterValue())
232+ matches := fuzzy.Find(query, words)
234+ sort.SliceStable(matches, func(i, j int) bool {
235+ return matches[i].Score > matches[j].Score
238+ var matchedItems []T
239+ for _, match := range matches {
240+ item := g.Items[match.Index]
241+ if i, ok := any(item).(HasMatchIndexes); ok {
242+ i.MatchIndexes(match.MatchedIndexes)
244+ matchedItems = append(matchedItems, item)
246+ if len(matchedItems) > 0 {
247+ newGroups = append(newGroups, Group[T]{
249+ Items: matchedItems,
227 cmds = append(cmds, f.groupedList.SetGroups(newGroups))
254 cmds = append(cmds, f.groupedList.SetGroups(newGroups))