Draggable items are positioned incorrectly when parent of Droppable has `transform`
72403 opened this issue · comments
Expected behavior
If I place a Droppable and Draggables in a div and add a transform to that div (e.g. transform="translateX(0%) translateY(0px) translateZ(0px)"
), Draggables should follow my mouse as I drag them.
Actual behavior
Items being dragged positioned way to the right. I originally thought they were disappearing when dragging, but if I drag my cursor way to the left they'll appear on the right side of the screen.
Steps to reproduce
- https://codesandbox.io/s/reverent-lucy-eibotf
- Drag an item around and it will disappear/be placed way to the right.
Suggested solution?
Not sure.
What version of React
are you using?
18.2.0
What version of @hello-pangea/dnd
are you running?
16.2.0
What browser are you using?
The issue appears in Firefox and Safari. I haven't tested Chrome.
Demo
I have the same issue.
When it's inside Modal (I'm using Mantine Modal), it's not positioned properly when it is dragging.
@coolneo4u @72403 Had the same issue. Went through the docs and found this:
Warning:
position: fixed
@hello-pangea/dnd
usesposition: fixed
to position the dragging element. This is quite robust and allows for you to haveposition: relative | absolute | fixed
parents. However, unfortunatelyposition:fixed
is impacted bytransform
(such astransform: rotate(10deg);
). This means that if you have atransform: *
on one of the parents of a<Draggable />
then the positioning logic will be incorrect while dragging. Lame! For most consumers this will not be an issue.
To get around this you can reparent your<Draggable />
. We do not enable this functionality by default as it has performance problems.
This fixed the issue for me.