-
Notifications
You must be signed in to change notification settings - Fork 656
Description
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!