Context menu with nothing added causes Javascript error

Context menu with nothing added causes Javascript error:

ContextMenu m = new ContextMenu();
m.setTarget(new Button("Hello"));

If the user right-click on the Hello button generates a Javascript error.

You can report these kinds of obvious errors directly to GitHub; I made you an example ticket about this case: https://github.com/vaadin/vaadin-context-menu-flow/issues/62

-Olli

That being said, I’m not certain what the behavior should be with an empty ContextMenu. Nothing happens? Empty list of items?

Olli Tietäväinen:
That being said, I’m not certain what the behavior should be with an empty ContextMenu. Nothing happens? Empty list of items?

This can happen only due to a programming mistake (a context menu with out any items in it doesn’t make any sense). So, it could be Ok to have nop for such a scenario.

I had a use case that used to work in previous versions of context menu: I created an empty context menu which was populated on the BeforeOpen event. This no longer works, and I get the error reported above.
This is the bug I submitted: https://github.com/vaadin/vaadin-grid-flow/issues/597