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

onDragOver gets triggered with onDragStart

Open ivanjeremic opened this issue 3 years ago • 3 comments

onDragOver gets triggered with onDragStart

version:

"@dnd-kit/core": "^6.0.5",
   "@dnd-kit/sortable": "^7.0.1",
   "@dnd-kit/utilities": "^3.2.0",

ivanjeremic avatar Dec 03 '22 15:12 ivanjeremic

Can you share a re-creatable example?

AbdurRahamanAR avatar Dec 21 '22 15:12 AbdurRahamanAR

This is most likely correct, because you are over your active item. If you check the over.id you should see that its equal to the active.id.

CronJorian avatar Feb 26 '23 22:02 CronJorian

The problem with this is that the screen reader will interrupt itself and never read the text for onDragStart. We could have onDragOver compare the two, but it can't differentiate between having just picked up the object vs dragging it back over itself.

Currently working around this by setting a piece of state in onDragStart and clearing it in onDragOver:

onDragStart({ active }) {
  setIsFirstTouch(true);
  return `Picked up draggable item ${active.id}.`;
},
onDragOver({ active, over }) {
  if (isFirstTouch) {
    setIsFirstTouch(false);
    return;
  }
  if (over) {
  ...

ArmandFrvr avatar Mar 28 '25 20:03 ArmandFrvr