Skip to content
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

Drag handles of a nested container also drag the parent container. #112

Closed
DeadHeadRussell opened this issue Dec 29, 2016 · 6 comments
Closed

Comments

@DeadHeadRussell
Copy link
Contributor

I have a nested container setup where both the parent elements and the child elements use handles. However, the drag handles of the children elements also drag the parent elements around (the first child handle will drag the first parent, while the second child element will drag the second parent element no matter which child container the child element is in).

I looked into the source code, and it looks like the SortableContainer.handleStart fires for both containers and they each search for the closest node with sortableInfo on it, which finds the child element. However, the containers do not check if that node is actually part of its collection.

A quick hack I found that fixes it is to add the manager to the sortableInfo field on the node: node.sortableInfo = { index, collection, manager: this.context.manager };. The handleStart method then checks this against its own manager: if (node.sortableInfo.manager != this.manager) { return; }.

If you want, I can submit a pull request with this, or a related fix. Just let me know!

@rsaccon
Copy link

rsaccon commented Dec 29, 2016

Just starting now to integrate react-sortable-hoc, I have the similar setup with nested containers, so I will run into the same issues I guess. So there is demand for a permanent fix !

@mikkelramlov
Copy link

mikkelramlov commented Jan 11, 2017

I have the exact same issue. A fix would be much appreciated.

@IceOnFire
Copy link

I would love to have such a fix: my uber-nested handles are starting dragging even siblings of their own parents!

@clauderic
Copy link
Owner

@DeadHeadRussell are you still interested in submitting a PR for this? If not I'll take a look within the next couple of days

@DeadHeadRussell
Copy link
Contributor Author

@clauderic Hey, sorry I was out of town for a few days. If you haven't started this yet, I can get it done on Thursday.

@clauderic
Copy link
Owner

Just released 0.4.10 with this fix! Again, thanks @DeadHeadRussell for taking the time to submit a PR for this ❤️

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

No branches or pull requests

5 participants