components icon indicating copy to clipboard operation
components copied to clipboard

drag events dataTransfer is undefined in RC5 alpha 7-2 with NgModule imports

Open jkyoutsey opened this issue 10 years ago • 4 comments

Bug, feature request, or proposal:

Bug: Since adding in Md*Module(s) and hammerjs, drag events no longer contain the dataTransfer property.

browser_adapter.js:84 TypeError: Cannot set property 'effectAllowed' of undefined
    at DraggableDirective.onDragStart (draggable.directive.ts:9)
    at DebugAppView._View_BusinessObjectFieldsListComponent1._handle_dragstart_0_0 (BusinessObjectFieldsListComponent.ngfactory.js:238)
    at view.js:381
    at dom_renderer.js:255
    at hammer_gestures.js:68
    at ZoneDelegate.invoke (zone.js:323)
    at Object.onInvoke (ng_zone_impl.js:53)
    at ZoneDelegate.invoke (zone.js:322)
    at Zone.runGuarded (zone.js:230)
    at NgZoneImpl.runInnerGuarded (ng_zone_impl.js:86)

This did not happen when directly using the Md* components in our components. Once we added the Md*Module(s) to NgModule and installed hammerjs this error arose.

What is the expected behavior?

drag events should have the dataTransfer property to be able to pass data in the dropped element

What is the current behavior?

error above

What are the steps to reproduce?

(I'm working on it, but can't figure out how to get ng2 rc5 and md alpha7-2 all in the same plunker...) Plunker template: http://plnkr.co/edit/o077B6uEiiIgkC0S06dd

Which versions of Angular, Material, OS, browsers are affected?

Angular 2 RC5 Material alpha 7-2 hammerjs 2.0.8 Windows 8.1 Chrome and FF latest

Is there anything else we should know?

It's worth noting that this error occurs in a component with NO MD components in use. But it only happens if we NgModule import the MD components (needed elsewhere in the application). It doesn't make sense, but our draggable div isn't an md-* component! But if I remove them from NgModule imports I can drag it!

jkyoutsey avatar Aug 12 '16 21:08 jkyoutsey

+1 hammerjs is overriding the original drag events with no way to access the original event.

ratscrew avatar Sep 14 '16 21:09 ratscrew

Why are "drag", "dragstart" and "dragend" being created as custom events, when they are native events?

https://github.com/angular/material2/blob/master/src/lib/core/gestures/MdGestureConfig.ts

Unless I missed something I don't think "drag", "dragstart" or "dragend" are being used in any component yet.

Thanks in advance :-)

ratscrew avatar Sep 15 '16 13:09 ratscrew

We removed dragstart and dragend, but we should also remove drag from gesture config. https://github.com/angular/material2/blob/b09465cda7cf8c74a5c903ee49d0366d644643d4/src/lib/core/gestures/MdGestureConfig.ts#L10-L10

jelbourn avatar Nov 03 '16 21:11 jelbourn

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.