Skip to content

Library kills other Drag / Drop behavior #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jameskerr opened this issue Mar 25, 2022 · 8 comments · Fixed by #33
Closed

Library kills other Drag / Drop behavior #17

jameskerr opened this issue Mar 25, 2022 · 8 comments · Fixed by #33

Comments

@jameskerr
Copy link
Contributor

It's reported that this happens. I am also aware that there can only be one instance of html5 backend on the page at once.

@Arthur-Ruthenberg
Copy link

It's reported that this happens. I am also aware that there can only be one instance of html5 backend on the page at once.

I found out that in one of the latest updates the HTML5Backend dependance that they use here it is possible to pass a root element that will allow 'localization' of this behavior only to the chosen component.

Hopefully someone can fix it.

@jameskerr
Copy link
Contributor Author

@Arthur-Ruthenberg thanks for the comment. Because I don't feel like I fully caught your message, let me ask: are you having this problem in your app with react-arborist? Or are you helping suggest a solution for how we might fix this?

@Arthur-Ruthenberg
Copy link

@jameskerr
Both.
I was trying to implement a simple dragging of an element in my project (I also have implemented the react-arborist there) and I stumbled upon this problem. The native onDrag event is being blocked by react-dnd-HTML5Backend library.
This library puts an event listener on the window.onDragStart which blocks any subsequent onDrag events.

I dug a little further within the react-dnd-HTML5Backend and they said there that sometime during the 2021 they made an improvement to the library to allow passing of a 'root' object to the dnd provider and it is supposed to fix this bug.

@jameskerr
Copy link
Contributor Author

Thank you for the research. Now I understand the issue. I do know of the "root" option you are referring to. If you are in a hurry, I'd welcome a contribution to react-arborist that adds a "dndRoot" option to the props and passes it to the react-dnd provider. Otherwise, I'll work on this as I have time. Thanks for your help!

@jameskerr
Copy link
Contributor Author

This is an issue with reactDnd: react-dnd/react-dnd#3344 This is unfortunate.

I will add a prop to the Tree component called dndRootElement so that you can scope the drag listeners to whatever element you want. If none is specified, it will default to window.

@jameskerr
Copy link
Contributor Author

@Arthur-Ruthenberg in the latest release (version 1.1.0) you can pass a dndRootElement prop to the tree to scope the event listeners. Let me know if that works for you!

@Arthur-Ruthenberg
Copy link

Arthur-Ruthenberg commented May 29, 2022

@jameskerr Thank you!
I will check it out ASAP!
I actually wanted to do it myself next weekend, but you beat me to it

@downright-development
Copy link

dndRootElement={document.getElementById('arborist-tree-wrapper')}

Whoa! This should be MUCH more advertised as a "gotcha" to watch out for. This single line solved a 1.5 day bug I was fighting. Thanks for a great library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants