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

Element with small height not draggable

Open lajanzen opened this issue 1 year ago • 1 comments

When I decrease the height of the draggable element, at some point the cursor to drag the element isn't shown anymore and I'm not able to drag the element, only resizing works.

Is there a possible fix for this?

I didn't need any specific config for this, the problem is already shown in your codesandbox example: https://codesandbox.io/p/sandbox/y3997qply9

https://github.com/user-attachments/assets/5dbd4235-f196-4e71-b536-c83d0b826f39

lajanzen avatar May 06 '25 12:05 lajanzen

I was having the same issue and just found a solution using resizeHandleStyles.

I did this:

    // Resize handle size is 10% of the widget size, but clamped between 8px and 24px.
    const handleWidth = Math.min(Math.max(width * 0.1, 8), 24);
    const handleHeight = Math.min(Math.max(height * 0.1, 8), 24);

    const resizeHandleStyles = {
      left: { width: `${handleWidth}px` },
      right: { width: `${handleWidth}px` },
      top: { height: `${handleHeight}px` },
      bottom: { height: `${handleHeight}px` },
      topLeft: { width: `${2 * handleWidth}px`, height: `${2 * handleHeight}px` },
      topRight: { width: `${2 * handleWidth}px`, height: `${2 * handleHeight}px` },
      bottomLeft: { width: `${2 * handleWidth}px`, height: `${2 * handleHeight}px` },
      bottomRight: { width: `${2 * handleWidth}px`, height: `${2 * handleHeight}px` },
    };

I used the double for the corners because I found it difficult to resize from the corners otherwise

AndreFavotto avatar Jul 29 '26 17:07 AndreFavotto