react-dnd / react-dnd-html5-backend

HTML5 backend for React DnD [Legacy Repo]
MIT License
145 stars 97 forks source link

Conflict on drop #32

Open chrisbuttery opened 8 years ago

chrisbuttery commented 8 years ago

I'm experiencing a slight conflict when dropping files into react-dropzone, resulting in the following errors.

Uncaught Invariant Violation: Expected targetIds to be an array
Uncaught Invariant Violation: Cannot call hover while not dragging.

Example:

boo

To get around this I have applied a conditional to handleTopDrop to check that dropTargetIds exists and has a length.

handleTopDrop(e) {
  const { dropTargetIds } = this;
  this.dropTargetIds = [];

  // Make sure we have dropTargetIds
  if (!dropTargetIds || !dropTargetIds.length) {
    return;
  }

  this.actions.hover(dropTargetIds, {
    clientOffset: getEventClientOffset(e)
  });

  ...

Example:

yay

This solves my issue and quite possibly could solve #25.