react-complex-tree icon indicating copy to clipboard operation
react-complex-tree copied to clipboard

Expose search string capability

Open downright-development opened this issue 7 months ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe. I would love to see a feature where the tree-sorting can happen through a provided search string, this would allow separate components (like a search bar) above the tree to filter the content.

For now, I can simply filter the data in a custom provider and re-shake the tree rendering, but this seems unnecessary :)

Describe the solution you'd like Expose a tree prop of "searchString" ... even cooler, expose a "search function" that would allow the user to search more than just a title

Describe alternatives you've considered Searching is built into the tree, but it's not overly intuitive for folks used to accessibility.

downright-development avatar Apr 06 '25 02:04 downright-development

There already exists functionality where users can enter search keywords and the tree visualizes search results over normal results, can you elaborate how your suggestion differs from that? Do I understand it correct that you suggest the tree should not visualize search-hits, but rather filter out non-hits in the search results and only render those items that are matched?

lukasbach avatar Apr 09 '25 20:04 lukasbach

There already exists functionality where users can enter search keywords and the tree visualizes search results over normal results, can you elaborate how your suggestion differs from that? Do I understand it correct that you suggest the tree should not visualize search-hits, but rather filter out non-hits in the search results and only render those items that are matched?

Yes -

https://github.com/brimdata/react-arborist?tab=readme-ov-file#tree-filtering

Similar to another react tree library, I can supply a search function and a search string - this allows me to search on some metadata on the row itself like tags, alongside the name/title of the row too :).

In Arborist, leveraging the search function will show the items (plus its parents) for matches.

This search string would be set in something separate from the tree itself.

Consider this sketch:

Image

downright-development avatar Apr 18 '25 01:04 downright-development