-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
Transformed SortableContext yields an offset drag overlay #464
Comments
Here's a demonstration: Screen.Recording.2021-04-30.at.18.40.50.mov |
#379 allows consumers to configure how to measure the draggable node, so I gave it a shot: const measuringConfig = {
draggable: {
measure: (element) => {
return {
...getBoundingClientRect(element),
left: getViewportLayoutRect(element).left
};
}
}
}; The result is better - there is no offset during drag 🎉 Screen.Recording.2021-09-30.at.9.42.18.mov |
This specific example is showing an x translation, but any translation (x/y) causes this bug. A y translation actually induces another bug with detecting where the element is in the list. It seems to push the item to the bottom of the list, regardless of where the overlay is positioned. |
@ranbena did you find a workaround for animation? |
Nah, I'm avoiding the use of transform till it's fixed :/ (using a non-gpu property animation in the meantime) |
@clauderic in my original post I provided a reproducible sandbox demo. Current: https://b2744.csb.app/ |
Hey @ranbena, The problem with your sandbox is that you're also rendering the It's generally recommended that you try to render the Here's a forked sandbox where that is the only change I made, everything seems to be working: https://codesandbox.io/s/dnd-kit-offset-forked-hbtwb?file=/src/App.js |
Understood. I'll try that 👍 |
Works! 🎉 |
This was really helpful! I had the same exact problem that was caused by some combination of flexbox layout containers. I'll see if I have time to PR a note about this being a good use case for React Portal in the dndkit docs article for DragOverlay. Edit: I found the documentation repo and see that a Portal example is in there! |
@clauderic what if the same issue of @ranbena occurs inside a modal of mui. As I am implementing dnd-kit inside the modal. |
@RahulRana0707 Did you figure something out? |
@RahulRana0707 @fmukaba Sorry for the late reply, but I was facing a similar issue with both a modal and drag overlay being portaled and directly attached to root div causing drag overlay to appear behind the modal. I solved it by increasing the z-index of the drag overlay to be greater than that of the modal. Hope this helps someone. Modals typically have a rather big z-index set by default so they appear over everything else so you might need to set the z-index of the drag overlay to be pretty big as well. |
When offsetting a SortableContext with css transform (for instance, when an open sidebar pushes it sideways), the drag overlay gets wrongly positioned.
Sandbox demo https://codesandbox.io/s/dnd-kit-offset-b2744
Originally posted by @ranbena in #205 (comment)
The text was updated successfully, but these errors were encountered: