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

Other elements are no longer dragged when Tree component is rendered #164

Closed santanamic closed 1 year ago

santanamic commented 1 year ago

Describe the bug I'm trying to use other drag and drop components on the same screen as the treeview component.

However, for any custom HTML element that I set the draggable attribute to, the drag functionality is lost. This only happens when the treeview component is rendered in the same view.

To Reproduce Try dragging some of the custom elements: https://codesandbox.io/embed/minimum-configuration-js-forked-c8uk64?fontsize=14&hidenavigation=1&theme=dark

Expected behavior The element drag and drop should happen (OnDrag). This only works when I remove the Tree component.

minop1205 commented 1 year ago

@santanamic

This problem is caused by the dependency package react-dnd. The same issue is reported in the following Issue.

https://github.com/react-dnd/react-dnd/issues/3304

This problem can be avoided by specifying rootElement in the DnDProvider option and limiting the scope of react-dnd. Please refer to the sample code we have created below.

https://codesandbox.io/s/issue164-zv2889?file=/src/App.jsx