ngx-contextmenu icon indicating copy to clipboard operation
ngx-contextmenu copied to clipboard

Angular 7.0.4: Can't read property disabled error

Open reenezden opened this issue 6 years ago • 7 comments

Describe the bug If I delete the package-lock.json and run npm install I have 5.1.1 of ngx-contextmenu in the recreated package-lock.json. When I right click I get the error:

TypeError: Cannot read property 'disabled' of undefined at ContextMenuAttachDirective.push../node_modules/ngx-contextmenu/fesm5/ngx-contextmenu.js. ContextMenuAttachDirective.onContextMenu (http://test.com:4200/vendor.js:201088:31) at Object.eval [as handleEvent] (ng:///SellerModule/ProductcalendarComponent.ngfactory.js:90:41) at handleEvent (http://test.com:4200/vendor.js:82259:41) at callWithDebugContext (http://test.com:4200/vendor.js:83353:25) at Object.debugHandleEvent [as handleEvent]

However if I run:

 npm install [email protected] 

the package-lock.json now has 5.0.1 and right click gives no error.

It seems to me 5.1.1 has an issue with Angular 7.0.4

See attached my package.json

To Reproduce If I delete the package-lock.json and run npm install I have 5.1.1 of ngx-contextmenu in the recreated package-lock.json. When I right click I get the error:

TypeError: Cannot read property 'disabled' of undefined at ContextMenuAttachDirective.push../node_modules/ngx-contextmenu/fesm5/ngx-contextmenu.js. ContextMenuAttachDirective.onContextMenu (http://test.com:4200/vendor.js:201088:31) at Object.eval [as handleEvent] (ng:///SellerModule/ProductcalendarComponent.ngfactory.js:90:41) at handleEvent (http://test.com:4200/vendor.js:82259:41) at callWithDebugContext (http://test.com:4200/vendor.js:83353:25) at Object.debugHandleEvent [as handleEvent]

Expected behavior It should show a pop up

reenezden avatar Dec 21 '18 09:12 reenezden

Hi,

I had the same issue. Resolved it with the following:

In the activating element you have: ... [contextMenu]="basicMenu" [contextMenuSubject]="item"

Ensure that you have the following in your context menu definition: ... <context-menu #basicMenu> ...

Regards

KarishImrith avatar Feb 19 '19 12:02 KarishImrith

Thanks alot @KarishImrith, I'm going to try you're fix and revert

reenezden avatar Feb 26 '19 01:02 reenezden

Thanks @KarishImrith , That worked for me 👍

TaruniSurampally avatar Jan 22 '20 05:01 TaruniSurampally

Hi,

I had the same issue. Resolved it with the following:

In the activating element you have: ... [contextMenu]="basicMenu" [contextMenuSubject]="item"

Ensure that you have the following in your context menu definition: ... <context-menu #basicMenu> ...

Regards

Its works good!

JoshuaEA123 avatar Jun 12 '20 06:06 JoshuaEA123

thanks @KarishImrith !!

JoshuaEA123 avatar Jun 12 '20 06:06 JoshuaEA123

I had this same issue. Thank you for the fix @KarishImrith!

davidjpfeiffer avatar Oct 21 '20 16:10 davidjpfeiffer

@KarishImrith Hello, I had the same issue in Angular 12.

Here is the error:- ERROR TypeError: Cannot read properties of undefined (reading 'disabled') at ContextMenuAttachDirective.onContextMenu (ngx-contextmenu.js:1309:1) at ContextMenuAttachDirective_contextmenu_HostBindingHandler (ngx-contextmenu.js:1322:119) at executeListenerWithErrorHandling (core.js:15327:1) at wrapListenerIn_markDirtyAndPreventDefault (core.js:15365:1) at HTMLDivElement. (platform-browser.js:561:1) at ZoneDelegate.invokeTask (zone.js:406:1) at Object.onInvokeTask (core.js:28679:1) at ZoneDelegate.invokeTask (zone.js:405:1) at Zone.runTask (zone.js:178:1) at ZoneTask.invokeTask [as invoke] (zone.js:487:1)

ketanpanther avatar Sep 07 '22 06:09 ketanpanther