clauderic / dnd-kit

The modern, lightweight, performant, accessible and extensible drag & drop toolkit for React.
http://dndkit.com
MIT License
12.89k stars 640 forks source link

Dragging gets stuck when long-pressing on Android #458

Closed churichard closed 2 years ago

churichard commented 3 years ago

I'm using MouseSensor and TouchSensor and dragging and dropping seems to work fine in Dev Tools, However, I just tried it out on my Android device today and noticed that the dragging and dropping is inconsistent.

This is what I have set up:

const sensors = useSensors(
    useSensor(MouseSensor, {
      activationConstraint: {
        distance: 10,
      },
    }),
    useSensor(TouchSensor, {
      activationConstraint: {
        delay: 250,
        tolerance: 5,
      },
    })
  );

I noticed that if I hold it for a short period of time and then start dragging, then the dragging works fine. However, if I hold it for a long time, then I feel my device vibrate and it gets stuck in place, like so:

https://user-images.githubusercontent.com/4218237/134080655-b48a1ef1-6f31-4340-ba9d-fb87dfa0c3af.mp4

And in Sentry, I get a TypeError: Cannot destructure property 'onCancel' of 'this.props' as it is undefined., which I think points to here: https://github.com/clauderic/dnd-kit/blob/1fe9b5c9d34237aae6ab22d54478c419d44a079a/packages/core/src/sensors/pointer/AbstractPointerSensor.ts#L217-L222

I don't have an onDragCancel handler set up on my DndContext -- just onDragStart and onDragEnd.

Perhaps dnd-kit is interacting weirdly with the native Android long press?

Originally posted by @churichard in https://github.com/clauderic/dnd-kit/issues/453#issuecomment-923352923

andres-calvo commented 3 years ago

Hello, @clauderic any news about this? I'm also experiencing this on Android. I would like to know if there has been any progress or how I can contribute. I'm using MouseSensor and TouchSensor, I have an onDragStart,onDragOver,onDragEnd and onDragCancel in my DnDContext.

andres-calvo commented 3 years ago

I recently discovered that this happen on my Android device. Android V10, but I tested on another phone with Android V11 and this doesn't happen. I tested it on Google Chrome Latest version, Opera GX, and the native browser, all of them giving me the same result, blocking after 5 seconds of long-pressing