Allow _click of MenuItem in a MenuBar
Currently MenuItem._click() seems to be tied to a contextMenu. If the parent is a menubar I guess it could fire a simple click event. (?)
Unfortunately MenuBarRootItem has package scope, so we can't search for that easily.
Yeah, that sounds pretty reasonable, thanks! It seems that the ContextMenu is there just to verify that the menu item is actually visible and enabled. Unfortunately that's not possible with MenuBar since it's not possible to retrieve the MenuBar instance from MenuItem. Opened a feature request here: https://github.com/vaadin/vaadin-menu-bar-flow/issues/83
As a workaround you can use menuBar._clickItemWithCaption("foo").
Alternatively I can implement menuBar._click(MenuItem).
That way one would need to lookup both components. I worked around with a helper
_get<MenuItem> { text = "Logfiles" }._menuBarClick()
That helper does not check anything, so probably using clickItemWithCaption would be better.
Alternatively I can implement
menuBar._click(MenuItem).
That would help in some places!
_get<MenuItem> { text = "Logfiles" }._menuBarClick()
Awesome workaround :-D Yet I'm hesitant to include this into Karibu-Testing since it's exactly as you said - no checks are done. Actually _get() performs the visibility checks, but doesn't check the enablement of the menu bar.
menuBar._click(MenuItem)
Thanks! This has been implemented in the commit #53fb104 and will be released with the next release of Karibu-Testing :+1:
Now that the workarounds are in place, let's wait for Vaadin folk to fix https://github.com/vaadin/vaadin-menu-bar-flow/issues/83 so that I can implement the _click() method properly.