bubbles icon indicating copy to clipboard operation
bubbles copied to clipboard

Activate filtering programmatically

Open revett opened this issue 2 years ago • 4 comments

Problem

I'm looking to enable filtering for my github.com/charmbracelet/bubbles/list component by default so that as soon as the list is rendered I can start to type, without needing to press the filter shortcut (/) first.

Recreate

  • Use the list-default example within the charmbracelet/bubbletea repo
  • Set m.list.SetFilteringEnabled(true) on line 82
  • Note that this does not do anything

I'm relatively new to the package so I think this needs to be done at a different point within the model lifecycle, rather than at the point of creation. Any help would be great 👍

revett avatar Dec 21 '21 18:12 revett

Hi! SetFilteringEnabled is actually for enabling and disabling filter functionality, not quite for triggering filtering. Based on my quick skimming of the code think we’ll need to add a method for you to be able to activate the filter programmatically.

Anyway, it’s a good idea, and we should definitely add it (surprised we haven’t, actually), though it will probably happen after the new year.

meowgorithm avatar Dec 21 '21 22:12 meowgorithm

@meowgorithm Any update around this?

joaom00 avatar Mar 20 '22 17:03 joaom00

I am facing the same issue. I just want to view filter input with a different key msg and use it for another purpose rather than filtering. But no way to achieve this. m.list.SetShowFilter() doesn't work and does not replace title. Any news on this issue?

akgunberk avatar Apr 06 '22 12:04 akgunberk

Same thoughts as @akgunberk: I would ideally just want to co-opt the same screen space the filtering currently takes up, but activate it with a different key and then just capture the input without any filtering.

usrme avatar May 12 '22 06:05 usrme