react-movable icon indicating copy to clipboard operation
react-movable copied to clipboard

Click events

Open goshua13 opened this issue 4 years ago • 4 comments

I have been trying to use onDoubleClick and onClick but those events are not working. do you have a workaround?

goshua13 avatar Sep 17 '21 20:09 goshua13

Any update on this? I'm having the same issue.

When I nest a button inside my draggable element and try to initiate a drag event by holding and moving my cursor(onMouseDown event to be more exact) over it - nothing works, which is very strange. The issue seems to be that react-movable initiates a drag during the onClick event, which makes interacting with any nested clickable elements pretty much impossible.

Perhaps we can change the logic here a little bit? For example, react-movable could listen for the onMouseDown event and initiate drag after some delay(~200ms)/or movement. This way, we could differentiate between the actual drag event and the onClick event.

AlexShRz avatar Jan 21 '22 15:01 AlexShRz

react-movable could listen for the onMouseDown

That's how it already works.

Can you provide an example?

tajo avatar Jan 23 '22 08:01 tajo

Sure! I created a small code sandbox that illustrates the problem: https://codesandbox.io/s/musing-dan-cbjs5?file=/src/App.tsx. In my case, buttons should act as drag handles and also preserve their original click functionality

AlexShRz avatar Jan 23 '22 11:01 AlexShRz

Oh, you can't have it both ways. I would recommend a dedicated drag handle button and another button next to it.

tajo avatar Feb 09 '22 00:02 tajo