minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
530 stars 71 forks source link

不具合報告:Cannot drag and drop node to root #63

Closed chris-oms closed 3 years ago

chris-oms commented 3 years ago

I'd like to be able to take a nested node and drag it to the root (so that it's parent becomes 0). Is this something that can be added?

minop1205 commented 3 years ago

@chris-oms Yes, it is possible. Please look at the following example.

example

In this example, I drop a node named Folder 2-1 into the root.

(in CodeSandbox) https://codesandbox.io/s/full-features-js-itczn

NOTE: To drop to the root, the route area must have a space. Therefore, you need to set the styles so that the height of the root node is secured.

Do you find the following App.jsx and App.module.css helpful?

App.jsx https://codesandbox.io/s/full-features-js-itczn?file=/src/App.jsx

App.module.css https://codesandbox.io/s/full-features-js-itczn?file=/src/App.module.css

chris-oms commented 3 years ago

@minop1205

Thanks for the quick reply, and yes you're completely right! Adding a bit of bottom padding did the trick for me. Thank you.