iannbing / react-simple-tree-menu

A simple React tree menu component
MIT License
137 stars 48 forks source link

Show parent nodes on search for children #194

Closed christianeide closed 3 years ago

christianeide commented 3 years ago

Hi! Thanks for a great package!

If you go to the basic example in the Storybook and search for Gekko, then Gekko is shown as expected. But is it possible to also show the parent nodes when you do this search? So that the hierarchy is visible?

Something like this: image

christianeide commented 3 years ago

For future reference: I solved this by adding a property childLabels to all parent elements with a substring of its children, like childLabels: "Squamata Gekko". Then i created a custom search where I also searched through that string for parent elements and returned true if match.

iannbing commented 3 years ago

@christianeide That's a smart workaround! Thanks for sharing.