@@ -198,30 +198,57 @@ func (f *filterableGroupList[T]) Filter(query string) tea.Cmd {
198198
199199 var newGroups []Group[T]
200200 for _, g := range f.groups {
201− words := make([]string, len(g.Items))
202− for i, item := range g.Items {
203− words[i] = strings.ToLower(item.FilterValue())
201+ // Check if group name matches the query
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)
207+ } else {
208+ // Fallback to using the section's ID or view content
209+ groupName = strings.ToLower(g.Section.ID())
204210 }
205−
206− matches := fuzzy.Find(query, words)
207−
208− sort.SliceStable(matches, func(i, j int) bool {
209− return matches[i].Score > matches[j].Score
210− })
211−
212− var matchedItems []T
213− for _, match := range matches {
214− item := g.Items[match.Index]
215− if i, ok := any(item).(HasMatchIndexes); ok {
216− i.MatchIndexes(match.MatchedIndexes)
211+ groupMatches := fuzzy.Find(query, []string{groupName})
212+
213+ if len(groupMatches) > 0 && groupMatches[0].Score > 0 {
214+ // If group name matches, include all items from this group
215+ // Clear any existing match indexes for items since the group matched
216+ for _, item := range g.Items {
217+ if i, ok := any(item).(HasMatchIndexes); ok {
218+ i.MatchIndexes(make([]int, 0))
219+ }
217220 }
218− matchedItems = append(matchedItems, item)
219− }
220− if len(matchedItems) > 0 {
221221 newGroups = append(newGroups, Group[T]{
222222 Section: g.Section,
223− Items: matchedItems,
223+ Items: g.Items,
224224 })
225+ } else {
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())
230+ }
231+
232+ matches := fuzzy.Find(query, words)
233+
234+ sort.SliceStable(matches, func(i, j int) bool {
235+ return matches[i].Score > matches[j].Score
236+ })
237+
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)
243+ }
244+ matchedItems = append(matchedItems, item)
245+ }
246+ if len(matchedItems) > 0 {
247+ newGroups = append(newGroups, Group[T]{
248+ Section: g.Section,
249+ Items: matchedItems,
250+ })
251+ }
225252 }
226253 }
227254 cmds = append(cmds, f.groupedList.SetGroups(newGroups))