charmbracelet / charmbracelet/bubbles

List: Expose setting of FilterValue and triggering filtering programmatically

Open
#129 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
8.9k
Forks
457
Avg merge
1d 18h
Merged PRs (30d)
5

Description

Hey guys,
when using list to show and filter a list of items it would be handy to be able to not only set items programmatically, but also set the `FilterValue` and triggering filtering programmatically.

Currently we have:

```
// FilterValue returns the current value of the filter.
func (m Model) FilterValue() string {
return m.FilterInput.Value()
}
```

so the FilterValue is directly tied to the `FilterInput` . I could theoretically hand everything down to the `FilterInput`, but that would be very tedious, when I have an external separate TextInput which might set the filter.

Especially, when the filterInput sets this:

`filterInput.Prompt = "Filter: "` - so there is no way to customize this.

So my wishlist would be:

- [ ] Add a `SetFilterValue`-func
- [ ] Add a `SetLiveFilteringEnabled`-func which determines if the list is automatically filtered via `FilterValue`
- [ ] Add a `Filter`-func that actually triggers filtering via `FilterValue`

Thanks for the awesome work!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.