Skip to content

Conversation

sissbruecker
Copy link
Contributor

Description

Improves the TestBench API for ContextMenu:

  • Modified ContextMenuElement.openByRightClick() to wait for a menu to open and return it. Throws an exception if no menu opens (behavior change).
  • Added ContextMenuElement.getMenuItems() to get all items from a menu
  • Added ContextMenuElement.getMenuItem(string) to find an item by text
  • Added ContextMenuElement.waitUntilClosed() to wait until a context menu has finished closing. Throws an exception if the menu does not close
  • Modified ContextMenuItemElement.openSubMenu() to wait for a submenu to open and return it. Throws an exception if no menu opens (behavior change).

Also deprecates ContextMenuOverlayElement. The class is now a proxy to ContextMenuElement and should thus keep working as before.

Fixes #7520

Type of change

  • Feature

*/
@Element("vaadin-context-menu-overlay")
@Element("vaadin-context-menu")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just remove ContextMenuOverlayElement completely? It was added quite recently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my intention as well, but since it was so easy to keep it working I thought why not keep it. We probably won't have to touch it again until we remove it.

Copy link

sonarqubecloud bot commented Aug 6, 2025

@sissbruecker sissbruecker merged commit 700d3f5 into main Aug 6, 2025
5 checks passed
@sissbruecker sissbruecker deleted the feat/context-menu-element-improvements branch August 6, 2025 08:16
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

Successfully merging this pull request may close these issues.

Refactor ContextMenu TestBench to not expose ContextMenuOverlayElement
2 participants