react-sortable-tree icon indicating copy to clipboard operation
react-sortable-tree copied to clipboard

DND auto expand issues

Open DharanBro opened this issue 8 years ago • 13 comments

Is there any way to disable the auto expand while performing the DND.

When my tree is big, auto expand misleading/confusing.

DharanBro avatar Oct 04 '17 06:10 DharanBro

I agree, it would be a very interesting feature to disable this auto-expand.

sylvaindubus avatar Oct 05 '17 18:10 sylvaindubus

Do you mean to say that when hovering over the destination node, the node should not expand at all?

lifejuggler avatar Nov 12 '17 22:11 lifejuggler

@lifejuggler Yes, exactly. So that we can have the source and destination tree node open and then we can do the drag and drop. We can provide this as a property. I have already modified in my project but I haven't added as a property. May be I can provide a PR, if this could be a useful feature from library itself.

DharanBro avatar Nov 13 '17 04:11 DharanBro

@DharanBro feel free to open a PR. adding a prop that work together canDrag / canDrop would be cool.

wuweiweiwu avatar Mar 27 '18 01:03 wuweiweiwu

I commented previously at https://github.com/frontend-collective/react-sortable-tree/issues/141#issuecomment-380611884 on why this is a major issue for users in our application.

I'd really like to see this added to the list at #281 - it's a very significant problem for many of our users.

buzztone avatar May 03 '18 00:05 buzztone

@buzztone how did you end up dealing with this? any temporary work around?

grydstedt avatar Oct 09 '18 12:10 grydstedt

Any update or work around for this issue?

tutap avatar May 25 '19 11:05 tutap

The best solution I could come up with is to only add children on expanded nodes. This requires having two tree data objects so you can check whether a node needs to have children added when it's expanded.

gragland avatar May 25 '19 18:05 gragland

Can anybody tell if this feature will be added and when? I've spent some time to workaround this but without any luck :/

dukoo avatar Feb 14 '20 10:02 dukoo

The best solution I could come up with is to only add children on expanded nodes. This requires having two tree data objects so you can check whether a node needs to have children added when it's expanded.

Thinking of the same. But deep cloning the bigger tree structure doesn't make sense. Also expand on holding over a node would be more intuitive.

DharanBro avatar Feb 18 '20 05:02 DharanBro

"Also expand on holding over a node would be more intuitive." - as I took a look at code it's not designed to handle holding one element over another. It's default behaviour is to swap nodes all the time.

dukoo avatar Feb 18 '20 07:02 dukoo

No idea if this is still relevant but this is how I solved this issue:

render() {
	this.isDragging = false;

	return <SortableTree
			// [ your default configuration... ],
			onDragStateChanged={({isDragging, draggedNode}) => {

				this.isDragging = isDragging;

			}}
			canNodeHaveChildren={node => this.isDragging ? node.expanded : true}
		/>
}

It simply only ensures that during a drag action canNodeHaveChildren only returns true when the node is already expanded.

aartrost avatar Sep 17 '20 17:09 aartrost

Isn't there any workaround or update to stop the nodes from autoexpanding on drag and drop?

chalscc avatar Jun 30 '22 14:06 chalscc