react-beautiful-dnd icon indicating copy to clipboard operation
react-beautiful-dnd copied to clipboard

Draggable item is not appearing next to the cursor

Open alexpuertasr opened this issue 3 years ago • 3 comments

I'm implemented an interactive list inside of a modal that appears from the right. For the animation of the modal I'm using react-spring, this one leave a transform: translateX(0px) when the animation is finish. For some reason with this css property react-beautiful-dnd is not able show the draggable item in the correct position

Expected behavior

The dragging item is appearing next to the cursor

Actual behavior

The dragging item is not appearing next to the cursor

Steps to reproduce

Add this styles in the parent where the react-beautiful-dnd is implemented:

position: absolute;
right: 0;
transform: translateX(0px);

What version of React are you using?

16.13.1

What version of react-beautiful-dnd are you running?

5.2.0

What browser are you using?

Chrome

Demo

Code: https://codesandbox.io/s/checklist-dnd-issue-ku2zf?file=/src/Checklist.jsx https://ku2zf.csb.app/

alexpuertasr avatar Oct 30 '20 14:10 alexpuertasr

I just do: image

and becomes work.

matheusAle avatar Nov 02 '20 16:11 matheusAle

I fixed it this way:

<Draggable key={id} draggableId={id} index={index}>
    {(provided) => (
        <li ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps}
            style={{ ...provided.draggableProps.style,
                      left: "auto !important",
                      top: "auto !important",
              }}>
                  ...      
        </li>
    )}
</Draggable>

Hope it helps :-)

durgeshm01722 avatar Sep 27 '23 13:09 durgeshm01722

I fixed it this way:

<Draggable key={id} draggableId={id} index={index}>
    {(provided) => (
        <li ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps}
            style={{ ...provided.draggableProps.style,
                      left: "auto !important",
                      top: "auto !important",
              }}>
                  ...      
        </li>
    )}
</Draggable>

Hope it helps :-)

It's the simplest way to solve this problem. But another issue: the dragged item will be coverd by the next item. (The prev's z-index is normal). I don't know why and how to solve it (it's useless when I force set z-index)

tywhisky avatar Jan 14 '24 15:01 tywhisky