ngx-contextmenu
ngx-contextmenu copied to clipboard
Angular 7.0.4: Can't read property disabled error
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
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
Thanks alot @KarishImrith, I'm going to try you're fix and revert
Thanks @KarishImrith , That worked for me 👍
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!
thanks @KarishImrith !!
I had this same issue. Thank you for the fix @KarishImrith!
@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.