-
Notifications
You must be signed in to change notification settings - Fork 89
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
Dynamic context menu open issue #95
Comments
Short answer: Yes, you need the setTimeout. Long answer: Without the setTimeout:
With the setTimeout:
I have no good explanation for why the execute isn't fired. |
Thank you for the explanation.
I think it might make sense to update your example with |
Yes, that's a valid use case and I agree that the |
We're having the same issue with using dynamic context menus. When looking at the code we identified the issue being the ContentChildren Input inside the ContextMenuDirective. As you mentioned it's the changeDetection that didn't update the values between setting the items and opening the context menu. We also tried to call the changedetection manually between the two lines of code but didn't work. Also calling setTimeout is not working properly. We have to use a specific time of milisecods to get it working. this.contextMenuActions = actions;
this.triggerChange();
if (!actions || !actions.length || actions.every(a => a.hidden)) {
return;
}
setTimeout(() => {
this.contextMenuService.show.next({
event: event.event,
contextMenu: this.contextMenuComponent,
item: null
});
this.triggerChange();
}, 450); In my opinion it's a very common use case to have one contextmenu and setting the entries dynamically with an ngFor. We're looking for a clean way to solve this, do you have any suggestions for us? |
Currently I need to use dynamic context menu like this (approximately):
onContextMenu by itself is a click event somewhere on a button.
Though if I remove setTimeout two issues appear:
Is there a reason for setTimeout call or am I doing something wrong?
The text was updated successfully, but these errors were encountered: