lukasbach / react-complex-tree

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

Can't drop items on an empty tree #182

Closed sweco-sedalh closed 1 year ago

sweco-sedalh commented 1 year ago

Describe the bug

Can't drop items on an empty tree (without any items).

To Reproduce Steps to reproduce the behavior:

  1. Setup an environment with two <Tree />s, one of which is empty
  2. Try to drag items from the tree that's not empty to the one that is
  3. Item cannot be dropped anywhere

https://codesandbox.io/s/react-complex-tree-playground-forked-96pwzt

Expected behavior A clear and concise description of what you expected to happen.

Dropping can happen on any part of the tree. Setting {min-,}{height,width} can be used to set a size for an empty tree, the entire of which is a valid drop target.

Screenshots

Desktop (please complete the following information):

Additional context

lukasbach commented 1 year ago

Hi @sweco-sedalh! Thanks for your report. This should now be working as of v2.0.0, please see this storybook as an example: https://rct.lukasbach.com/storybook/?path=/story/core-basic-examples--drop-on-empty-tree

Please note that the drag-over needs to be performed over the tree container component for it to register on empty trees, so the tree container component needs a minimum height for it to work. You can customize this by giving a minimum height to the component rendered with renderTreeContainer which receives the containerProps.

sweco-sedalh commented 1 year ago

Thanks, I can can confirm that this issue is resolved in 2.0.0!