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

feat: drop as sibling to open folder

Open cha0s opened this issue 2 years ago • 10 comments

Somewhat related to #140 and #144

Instead of having to fuss about internal nodes and hovering, it seem to me that the real solution is just to allow dropping nodes as siblings of open folders (and not always as children).

This is a fix I'm testing, though you may identify some issue with it. It seems to do the right thing. I thought I'd start a conversation! :)

cha0s avatar Jun 13 '23 07:06 cha0s

I noticed that the parentId is not correct when inspecting onMove. So it definitely needs work.

cha0s avatar Jun 13 '23 07:06 cha0s

Pushed a fix that seems to take care of the issue.

cha0s avatar Jun 13 '23 07:06 cha0s

Thanks for your contribution. You may be trying to achieve something else, but the feature of dropping a node as a sibling to an open folder is already possible. You must drag it to the bottom of it's children, them move the cursor to the left.

In the following video, I drag the item as the sibling of the open folder first, then as a child of the open folder. Notice the dotted line cursor moving between indent levels. This indicates where it will placed, sibling or child.

https://github.com/brimdata/react-arborist/assets/3460638/4ed69dab-a533-405b-930d-37dbec72e22a

Are you trying to achieve something different? Maybe you can record a video of your desired behavior.

Thanks!

jameskerr avatar Jun 13 '23 19:06 jameskerr

My use case is a tree with nodes that all have a children array (in other words, they may all be arranged as children of each other).

Without this fix, it is not possible to move any node as a sibling of another; you are only allowed to move them under each other.

I can provide a video if you need.

cha0s avatar Jun 14 '23 13:06 cha0s

My comment may not have been clear about the fact that I do understand the 'drag left' behavior! This PR just allows you to drag left in the case that I described, when all nodes are open folders.

cha0s avatar Jun 14 '23 13:06 cha0s

I think I see what you mean. If you could provide a demo of the library not working, that would be helpful. I'll need to test this. Thanks for the contribution.

jameskerr avatar Jun 15 '23 22:06 jameskerr

Agree on this, having same issues

TheMichaelLant avatar Aug 23 '23 22:08 TheMichaelLant

Any progress on this? Would love to see this merged..

killerbane avatar Aug 25 '23 08:08 killerbane

Ok, I think I see the issue here. If anyone would like to make a demo showcasing how to have a tree full of open nodes, that would help move this along. Otherwise, I'll need to get around to making an example to test.

I'll also need to ensure the current behavior doesn't break.

jameskerr avatar Aug 28 '23 20:08 jameskerr

I believe I've been having the same issues. In short I needed to be able to add siblings to open empty non-leaf nodes. This PR should solve the problem: https://github.com/brimdata/react-arborist/pull/199

There are two videos in the PR description showing the problem and the solved variant. Thank you for an awesome package!

edimov avatar Dec 09 '23 19:12 edimov