react-arborist
react-arborist copied to clipboard
Easy api to prevent nodes from being selectable
trafficstars
This is possible today, but maybe we could make an easier api.
Today, you'd make a custom RowRenderer and NodeRenderer. Then in there, you'd prevent selection if that node meets a certain criteria. An Tree Prop would make it all easier.
First of all, thank you for such a great library! 🙏
I think the tree prop is very important. The solution you describe won't cover all the cases, only the mouse selection.
- The user can still select the "unselectable" nodes by keyboard. This can be solved by using custom Container, but then the user needs to reimplement most of the keyboard functionality by himself...
- TreeApi calls
this.select()in a few places, increateand infocus. I currently can't think of some nice workaround for this.
So, the API for preventing nodes selection is crucial, maybe disableSelect?: string | boolean | BoolFunc<T>, in the spirit of disableEdit/disableDrag. WDYT?
Yes, that is a good point. I think your proposed api is sound.