Skip to content

feat: add lookup of context menus attached to a component - #10269

Merged
sissbruecker merged 3 commits into
mainfrom
feat/context-menu-lookup
Sep 29, 2026
Merged

sissbruecker merged 3 commits into
mainfrom
feat/context-menu-lookup

Conversation

@mvysny

@mvysny mvysny commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #1520
Fixes #1514

  • Added static ContextMenu.getContextMenus(Component) and GridContextMenu.getContextMenus(Grid) returning the menus of that type that target a component, in the order their target was set
    • setTarget() keeps the list up to date when a target is set, replaced or cleared
    • It returns a list because one component can have several menus, e.g. one opened by left click and one by right click
  • Added Grid.getContextMenus() returning the GridContextMenu instances that target the grid
  • Added unit tests for both methods

The main use case is browserless testing (Karibu-Testing), where a test needs to find a menu that application code created. The target already holds a reference to the menu through its before-open listener, so storing the menu in the target's ComponentUtil data does not keep anything in memory longer than before.

Type of change

  • Feature

Note

Reviewed by Martin Vysny (@mvysny) before opening this PR.

Reviewed-by: Martin Vysny <mavi@vaadin.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the changes — left 1 comment.

Finding
🧪 No test covers clearing one menu's target when the target has several menus.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sissbruecker

Copy link
Copy Markdown
Member

@mvysny Should the mentioned issues be tagged as closed, or is there anything else in them that has not been solved? From a quick glance I'd say this PR resolves them.

@mvysny

mvysny commented Sep 29, 2026 •

Copy link
Copy Markdown
Member Author

@sissbruecker agree, this PR solves both #1520 and #1514 fully.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@sissbruecker
sissbruecker added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit be9c91c Sep 29, 2026
28 of 30 checks passed
@sissbruecker
sissbruecker deleted the feat/context-menu-lookup branch September 29, 2026 08:23
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow retrieval of ContextMenu attached to given Component Add Grid.getContextMenu()

4 participants