Exception during onDragLeave #272

Open
opened 2016-06-23 13:42:40 +00:00 by ediri · 0 comments
ediri commented 2016-06-23 13:42:40 +00:00 (Migrated from github.com)

When i create a drop zone for files and i did not dropped the file i get following error message:

browser_adapter.ts:74 TypeError: Cannot read property '0' of undefined at FileDropDirective.onDragLeave (file-drop.directive.ts:54) at AppView._View_MessageUploadComponent0._handle_dragleave_8_3 (MessageUploadComponent.template.js:224) at eval (MessageUploadComponent.template.js:92) at eval (view.ts:397) at eval (dom_renderer.ts:299) at eval (dom_events.ts:16) at ZoneDelegate.invoke (zone.js:303) at Object.onInvoke (ng_zone_impl.ts:66) at ZoneDelegate.invoke (zone.js:303) at Zone.runGuarded (zone.js:217)

the code in file-drop-directive.ts is following

@HostListener('dragleave', ['$event']) public onDragLeave(event:any):any { if (event.currentTarget === (this as any).element[0]) { return; } this._preventAndStop(event); this.fileOver.emit(false); }

So the error is that (this as any).element[0]) is undefined.

I modifed the code to

@HostListener('dragleave', ['$event']) public onDragLeave(event:any):any { if ((this as any).element) { if (event.currentTarget === (this as any).element[0]) { return; } } this._preventAndStop(event); this.fileOver.emit(false); }

And now it works fine!

Can sombody confirm this? My drop zone code is nearly identically with the example code!

When i create a drop zone for files and i did not dropped the file i get following error message: `browser_adapter.ts:74 TypeError: Cannot read property '0' of undefined at FileDropDirective.onDragLeave (file-drop.directive.ts:54) at AppView._View_MessageUploadComponent0._handle_dragleave_8_3 (MessageUploadComponent.template.js:224) at eval (MessageUploadComponent.template.js:92) at eval (view.ts:397) at eval (dom_renderer.ts:299) at eval (dom_events.ts:16) at ZoneDelegate.invoke (zone.js:303) at Object.onInvoke (ng_zone_impl.ts:66) at ZoneDelegate.invoke (zone.js:303) at Zone.runGuarded (zone.js:217)` the code in file-drop-directive.ts is following `@HostListener('dragleave', ['$event']) public onDragLeave(event:any):any { if (event.currentTarget === (this as any).element[0]) { return; } this._preventAndStop(event); this.fileOver.emit(false); }` So the error is that (this as any).element[0]) is undefined. I modifed the code to `@HostListener('dragleave', ['$event']) public onDragLeave(event:any):any { if ((this as any).element) { if (event.currentTarget === (this as any).element[0]) { return; } } this._preventAndStop(event); this.fileOver.emit(false); }` And now it works fine! Can sombody confirm this? My drop zone code is nearly identically with the example code!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#272