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

Allow _click of MenuItem in a MenuBar #33

Open
eiswind opened this issue May 1, 2020 · 5 comments
Open

Allow _click of MenuItem in a MenuBar #33

eiswind opened this issue May 1, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request waiting upstream Something needs to be implemented in a dependency

Comments

@eiswind
Copy link
Contributor

eiswind commented May 1, 2020

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.

@mvysny mvysny self-assigned this May 1, 2020
@mvysny mvysny added the enhancement New feature or request label May 1, 2020
@mvysny
Copy link
Owner

mvysny commented May 1, 2020

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").

@mvysny mvysny added the waiting upstream Something needs to be implemented in a dependency label May 1, 2020
@mvysny
Copy link
Owner

mvysny commented May 1, 2020

Alternatively I can implement menuBar._click(MenuItem).

@eiswind
Copy link
Contributor Author

eiswind commented May 2, 2020

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.

@eiswind
Copy link
Contributor Author

eiswind commented May 4, 2020

Alternatively I can implement menuBar._click(MenuItem).

That would help in some places!

@mvysny
Copy link
Owner

mvysny commented May 4, 2020

_get { 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 👍

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting upstream Something needs to be implemented in a dependency
Projects
None yet
Development

No branches or pull requests

2 participants