react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Easy api to prevent nodes from being selectable

Open jameskerr opened this issue 3 years ago • 2 comments
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.

jameskerr avatar Oct 28 '22 15:10 jameskerr

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.

  1. 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...
  2. TreeApi calls this.select() in a few places, in create and in focus. 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?

boriskor avatar Jul 25 '23 14:07 boriskor

Yes, that is a good point. I think your proposed api is sound.

jameskerr avatar Jul 25 '23 16:07 jameskerr