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

How can we use `renderContainer`?

Open donnguyen opened this issue 1 year ago • 3 comments

Hi there,

I am trying to write a custom container for our tree but can't find any document on renderContainer? Just reading the code, the renderContainer provides no tree-api access, so not sure if it is even possible to have a custom one?

Thanks for the great works!

Cheers

donnguyen avatar Oct 24 '22 13:10 donnguyen

Hi @donnguyen, I didn't document it because I wasn't sure if should be public api yet. I think the way it currently exists, it's not difficult and awkward to make a custom one. The default has too many internal dependencies.

What are your needs for a custom container? I would guess you want to control the keyboard shortcuts?

jameskerr avatar Oct 24 '22 16:10 jameskerr

Hi @jameskerr, thanks for getting back to me.

We would need more than just the keyboard shortcuts. Actually we are having many small issues with the UI, how the absolute position works. You know, it is good, but not so great, we don't want the x scrollbar etc. We are trying to do something like Google Drive doing with their sidebar, it can automatically increase the width to fit the tree if necessary. It is not so easy to do with absolute position. I know all these come from FixedSizeList, not react-arborist itself, so I am just trying to customise the container to go with something like https://github.com/petyosi/react-virtuoso. I guess it might help.

donnguyen avatar Oct 25 '22 01:10 donnguyen

@donnguyen sounds good. With the right css styling I'm able to make the tree items expand to fill their container. Here's a demo page: https://react-arborist.netlify.app/cities

jameskerr avatar Oct 25 '22 23:10 jameskerr