atlassian / react-beautiful-dnd

Beautiful and accessible drag and drop for lists with React
https://react-beautiful-dnd.netlify.app
Other
33.17k stars 2.53k forks source link

Unable to drag with the mouse while Ctrl button is pressed #1678

Open inkas opened 4 years ago

inkas commented 4 years ago

Expected behavior

While holding the Ctrl button you should be able to drag with the mouse

Actual behavior

When a Ctrl button is pressed the mouse dragging is disabled. Instead, only a focus is added to the draggable

Steps to reproduce

Press and hold the Ctrl button and try to drag with the mouse

Suggested solution?

I couldn't find any documentation for manual key mapping. It would be great if I could somehow detect a mouse drag while Ctrl button is being pressed. I want to do copy of the draggable if Ctrl is pressed, otherwise simply move it to the droppable column.

What version of React are you using?

16.12.0

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

12.2.0

What browser are you using?

Chrome 79

Demo

dnd

alexreardon commented 4 years ago

Right now we do not allow dragging if button is pressed when the mouse down occurs. This is done in order to try and play well with other browser interactions.

Just so I understand, you would like there to be some way to add a keyboard modifier to dragging?

inkas commented 4 years ago

Exactly. But disabled dragging while a key is pressed is the main issue. I thought disabling keyboard dragging will solve this issue, however it can not be disabled at this point #1683

alexreardon commented 4 years ago

I hope that will be resolved soon ^

mofojed commented 4 years ago

Just to add to this - I think the code blocking drag starting while modifier key is pressed is here: https://github.com/atlassian/react-beautiful-dnd/blob/24a8e6021600920c0b2a28f89d5ffb17538fe96c/src/view/use-sensor-marshal/sensors/use-mouse-sensor.js#L227

I'm implementing a multi drag and drop solution using react-beautiful-dnd, and everything is working great, but it would be extra awesome if we could have the drop start while user is still holding down Shift or Ctrl/Cmd, to align more with other drag and drop scenarios. We could add custom sensors I think? But really only want to change that one line in the one sensor. Maybe if sensors were exported, and there was a param configurable in the mouse sensor, that would be the best solution: https://github.com/atlassian/react-beautiful-dnd/issues/1698

EnglederLucas commented 3 years ago

Any updates on this? I've been struggling with this for a few days. I tried reimplementing my own mouse sensor without this line with no success.

Furthermore, I thought that this code would allow pressing other keys while dragging, but it doesn't seem to be the case. When pressing "a" for example, the dragging is blocked just like when pressing CTRL. I did it just like it was suggested here #1683

<DragDropContext
    onDragEnd={res => onDragged(res)}
    enableDefaultSensors={true}
    sensors={[useMouseSensor]}
>
NaagAI commented 4 months ago

Right now we do not allow dragging if button is pressed when the mouse down occurs. This is done in order to try and play well with other browser interactions.

Just so I understand, you would like there to be some way to add a keyboard modifier to dragging?

Hi @alexreardon - is this keyboard modifier to allow dragging done? I would like to do Ctrl + click to drag and copy

NaagAI commented 4 months ago

I tried doing 'isdragdisabled'= FALSE when CTRL key is pressed but still no luck. Can you please help @alexreardon ?

NaagAI commented 4 months ago

I hope that will be resolved soon ^

Hi @alexreardon - please let us know if you had time to review/resolve this? Badly in need of this feature

Alex3496 commented 2 months ago

There is still no solution for this case?