ng2-dnd icon indicating copy to clipboard operation
ng2-dnd copied to clipboard

TypeError: Cannot read property 'cursor' of undefined

Open NateGriffin opened this issue 7 years ago • 5 comments

I'm submitting a ... [x ] bug report [ ] feature request [ ] question about the decisions made in the repository

Do you want to request a feature or report a bug?

What is the current behavior? Does not compile

What I do is:

start running project in Visual Studio I currently use Webpack.

What is the expected behavior? to compile

Please tell us about your environment: dragNdrop-ng2.4.9 I get and error that starts with the following whenever I start running the application: "Exception: Call to Node module failed with error: Error: Uncaught (in promise): TypeError: Cannot read property 'cursor' of undefined TypeError: Cannot read property 'cursor' of undefined"

It seems to only occur when starting a component that features draggable components. If I load the app without them it works fine.

Angular version: 2.4.4 Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

NateGriffin avatar Mar 16 '17 13:03 NateGriffin

same here

stuartaccent avatar May 04 '17 10:05 stuartaccent

same here

natilivni avatar Jul 03 '17 11:07 natilivni

Any update on this ? For me this only happens when I reload the page where I am using ng2-dnd, otherwise the page works perfectly fine. Please update this thread if there is any work around on this.

Thanks

imraqes avatar Aug 29 '17 12:08 imraqes

I decided to revisit this and after lots of digging around i have found what my issue was. It was because I was setting the dnd-sortable-container directive on an <ng-container>. Changing it to a <div> fixed it.

I assume the issue is something to do with the type of element an ng-container is and nativeElement as the recent change that broke it for me was https://github.com/akserg/ng2-dnd/commit/6c08842989139430516e142cca74165fc0d36d1b#diff-f55efd0d37300ccf1f787abc6aa003af

Hope this helps you guys out @natilivni, @imraqes, @NateGriffin

Just to expand on this, the reason is ng-container's nativeElement is a comment in the html which does not have a style attr. So that change above is not able to add the cursor style which is why it breaks.

stuartaccent avatar Sep 09 '17 01:09 stuartaccent

I am seeing this error on 4.2.0, but only in AoT. We are creating a draggable component programmatically, and passing in an elementRef that is a <div>, so I'm not clear why it wouldn't have a style attribute.

mrkvw avatar Jan 30 '18 01:01 mrkvw