dnd-kit icon indicating copy to clipboard operation
dnd-kit copied to clipboard

shouldCancelStart?

Open nuthinking opened this issue 1 year ago • 1 comments

I'm trying to migrate a project from react-sortable-hoc. What's the equivalent of shouldCancelStart? How can I prevent the drag to start on runtime? Thanks! 🙏

nuthinking avatar Feb 24 '24 15:02 nuthinking

I resolved with a custom Sensor:

class CustomPointerSensor extends PointerSensor {
  static activators = [
    {
      eventName: 'onPointerDown' as const,
      handler: ({ nativeEvent: event }: PointerEvent): boolean => {
        if (document.querySelector(...)) {
          return false;
        }
        return true;
      }
    }
  ];
}

nuthinking avatar Feb 25 '24 08:02 nuthinking