Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SetFilterText and SetFilterState #335

Merged
merged 6 commits into from
Sep 10, 2024

Conversation

taigrr
Copy link
Contributor

@taigrr taigrr commented Feb 21, 2023

Currently, there's no way to allow a developer to prefill a list filter reliably. A workaround of using Program.Send works, but is limiting.

This PR introduces two new functions, SetFilterText and SetFilterState which fix this issue and allow for finer control over the list's initial filter state.

Willing to make whatever style changes etc. are required.

@taigrr
Copy link
Contributor Author

taigrr commented Feb 21, 2023

This also addresses #85 but in a different way than #201

@taigrr
Copy link
Contributor Author

taigrr commented Feb 22, 2023

thanks for the tests (both manual and programmatic) @k-x7 !

@taigrr
Copy link
Contributor Author

taigrr commented Sep 26, 2023

@caarlos0 / @maaslalani any chance I could get this revisited?

@lorenzo-milicia
Copy link

lorenzo-milicia commented Sep 27, 2023

This implementation does not set the filteredItems list to be the whole list when the state is set to Filtering and the FilterInput has empty string as value. I would add the same code found in the switch to the Filtering state by key press:

if m.FilterInput.Value() == "" {
  // Populate filter with all items only if the filter is empty.
  m.filteredItems = m.itemsAsFilterItems()
}

@ajayd-san
Copy link

Hey,
Is there a reason why this is not yet merged? I'd like to work on it if no one else is.

@aexvir
Copy link

aexvir commented Aug 5, 2024

also interested in this one :/ anything that can be done to get this merged?

@caarlos0 caarlos0 added the enhancement New feature or request label Aug 13, 2024
@taigrr
Copy link
Contributor Author

taigrr commented Sep 10, 2024

Nearing the 1 year anniversary of my last bump request :)

Does the second approval mean we're closer to a merge?

@caarlos0 caarlos0 merged commit d019ed3 into charmbracelet:master Sep 10, 2024
@caarlos0
Copy link
Member

caarlos0 commented Sep 10, 2024

thanks @taigrr , sorry for the delay merging this ❤️

@taigrr
Copy link
Contributor Author

taigrr commented Sep 10, 2024

Awesome. No worries, I know y'all are busy and this adds exported functionality to the API, it should be vetted thoroughly :)

@meowgorithm
Copy link
Member

Thanks for your patience with this one @taigrr ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants