Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling an entry gives " Cannot read property 'data' of null" #740

Open
crystalfp opened this issue Nov 23, 2020 · 1 comment
Open

Disabling an entry gives " Cannot read property 'data' of null" #740

crystalfp opened this issue Nov 23, 2020 · 1 comment

Comments

@crystalfp
Copy link

I'm using 3.0.0-beta.2 inside Chrome.
To update the enabled/disabled status of an entry of the menu the only solution I have found is to put a

disable: (): boolean => {
	return projectStatus === "ACTIVE";
}

in the entry and then have:

events: {
	show: (): boolean => {
		$.contextMenu("update");
		return true;
}

But when I open the menu the following error appears:

ContextMenuOperations.js:488 Uncaught TypeError: Cannot read property 'data' of null
    at HTMLUListElement.<anonymous> (ContextMenuOperations.js:488)
    at Function.each (jquery.min.js:2)
    at S.fn.init.each (jquery.min.js:2)
    at e.value (ContextMenuOperations.js:487)
    at e.value (ContextMenuOperations.js:521)
    at ContextMenu.js:278
    at Array.forEach (<anonymous>)
    at e.value (ContextMenu.js:277)
    at e.value (ContextMenu.js:53)
    at Function.c [as contextMenu] (contextmenu.js:34)
(anonymous) @ ContextMenuOperations.js:488
each @ jquery.min.js:2
each @ jquery.min.js:2
value @ ContextMenuOperations.js:487
value @ ContextMenuOperations.js:521
(anonymous) @ ContextMenu.js:278
value @ ContextMenu.js:277
value @ ContextMenu.js:53
c @ contextmenu.js:34
show @ prj-list.ts:143
value @ ContextMenuOperations.js:36
value @ ContextMenuEventHandler.js:100
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2

Is this the correct way or there is another method to be used to enable/disable an entry (and change the name, but this is the next step).
Thanks for looking!
mario

@crystalfp
Copy link
Author

Dirty workaround found.
In node_modules/jquery-contextmenu/dist/jquery.contextMenu.js change line 994 to:

                // e.data.manager.operations.resize(e, $(element), true);
                element.data.manager.operations.resize(e, $(element), true);

Then comment line 1015

                // rootMenuData.manager.operations.resize(e, currentMenuData.$menu);

In my previous entry correct disable: to disabled:
And now, at least for me, it works!
BTW, I'm using beta 3.x
Hope this project revives, It is so useful and I don't have found any alternative so powerful and flexible.
Thanks!
mario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant