mharris717 / ember-drag-drop

Drag and Drop Addon for Ember CLI
MIT License
204 stars 141 forks source link

Adding `types` properties into mocked DataTransfer #191

Open GabrielCousin opened 3 years ago

GabrielCousin commented 3 years ago

Hey there!

We've been using this addon quite intensively lately, thanks for the hard work! In order to be able to check the validity of the drag event, we ended up doing this:

import DraggableObjectTarget from 'ember-drag-drop/components/draggable-object-target';

export default class CustomDraggableObjectTarget extends DraggableObjectTarget {
  validateDragEvent(event) {
    return event.dataTransfer.types.length === 1 && event.dataTransfer.types.includes('text/plain');
  }
}

But the problem introduced is that we can no longer use the drag test-helper. This PR aims at adding a types property in the mocked DataTransfer :)

Let me know if you see anything I may rework!

Thanks!

GabrielCousin commented 2 years ago

Hi @mharris717! Any chance you can have a look at this or discuss anything that may look wrong to you? Thanks a lot 🙌