lukasbach / react-complex-tree

Unopinionated Accessible Tree Component with Multi-Select and Drag-And-Drop
https://rct.lukasbach.com
MIT License
961 stars 77 forks source link

Reposition the Search input and make it permanent without having to use custom RenderSearchInput #383

Open coreymunn3 opened 4 months ago

coreymunn3 commented 4 months ago

Is your feature request related to a problem? Please describe. The search input bar does not follow best practices for user input. The search bar is impermanent and displays at the bottom of the tree, which is not guaranteed to be in view when the user begins typing. Because it is impermanent the user is not aware of the existence of search functionality without being explicitly told so and this can create bad experiences.

Describe the solution you'd like I'd like to be able to make the search input permanently displaying (i.e. you don't have to start typing for it to show up, it just always is visible to the user) and I'd like to be able to position it at the top of tree, rather than the bottom.

Describe alternatives you've considered I could use the renderSearchInput for this, but when you do so you lose all in-built search functionality and have to program it yourself. Feels like alot of work when All I really want is to change the display settings of the existing input. At least, that's my perspective as of now, please inform if there's a better option for my use case.

Additional context N/a

lukasbach commented 3 months ago

The reason why I built the search how I did, is mostly motivated by how tree searches work in some IDEs like IntelliJ:

rct-search-motivation

They fulfill the accessibility requirement that, when starting to enter a key, the focus should jump to the visible item that starts with that key, and ideally continuing to enter keys should refine the focus. The input is not shown by default, because it's not always desired in all use cases and the primary use case is really just a "quickly jump to item x".

It's actually not that complicated to build a custom search on top of RCT. The built-in search only searches visible items, so childs of opened folders, here is an example for a custom implementation for a searching hidden items with a seperate search input:

https://rct.lukasbach.com/storybook/?path=/story/core-finding-items--custom-finder Source code: https://github.com/lukasbach/react-complex-tree/blob/main/packages/core/src/stories/FindingItems.stories.tsx