feat!: add tooltip APIs to context-menu and menu-bar items#9223
Open
feat!: add tooltip APIs to context-menu and menu-bar items#9223
Conversation
Adds setTooltipText and setTooltipPosition for menu items based on upcoming web-components support (vaadin/web-components#11549). - ContextMenuBase gains setTooltipText / setTooltipPosition; the slotted <vaadin-tooltip> is auto-attached on first use and shared by root and sub-menu items. - MenuBar gains setTooltipPosition, and existing setTooltipText now also targets sub-menu items. - Connectors propagate tooltip and tooltipPosition for every item in the tree (recursively for menu-bar) so the web component's tooltip controller sees the values. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move `setTooltipText` and `setTooltipPosition` from `ContextMenuBase` and `MenuBar` onto `MenuItemBase` so tooltips are configured directly on items. Add matching `addItem(..., tooltipText)` overloads on `ContextMenuBase` and `SubMenu` for parity with `MenuBar`. Wire `MenuBarItem` to delegate tooltip element setup and updates back to its owning `MenuBar`. Expand integration tests to cover root and sub-menu items, tooltip position overrides, tooltip updates, and detach/attach cycles. Enable `accessibleDisabledMenuItems` and `accessibleDisabledButtons` feature flags in IT modules so disabled items still receive hover tooltips.
c02f595 to
7c6ab85
Compare
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Restore deprecated MenuBar.setTooltipText(MenuItem, String) delegating to MenuItem.setTooltipText for source compatibility with #5294 era callers. - Route MenuBarItem tooltip updates through resetContent so the items tree is fully regenerated; generateItemsTree in contextMenuConnector already copies tooltip and tooltipPosition recursively, so the manual refreshTooltips walk in menubarConnector is dropped. - Revert menuItemsArrayGenerator field in ContextMenuBase to private; the package-private leftover from an earlier draft is no longer needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Trim implementation details from setTooltipText / setTooltipPosition javadoc on MenuItemBase. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add (text|component, tooltipText) and (text|component, tooltipText, listener) overloads on MenuManager so ContextMenuBase, SubMenu and MenuBar all delegate to a single implementation. Replace the package-private scheduleTooltipUpdate hooks on ContextMenuBase and MenuItemBase with the existing contentReset SerializableRunnable, which runs the same generate/reset path. MenuItemBase now stores contentReset and calls it directly from setTooltipText / setTooltipPosition. MenuBarItem no longer needs its scheduleTooltipUpdate override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Making ensureTooltipElement abstract broke GridMenuItem, which has no override of its own. The default implementation that delegates to contextMenu works for both grid and context-menu items; MenuBarItem keeps its own override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
web-padawan
reviewed
May 4, 2026
| }); | ||
| updateTooltips.setId("update-tooltips"); | ||
|
|
||
| add(attach, detach, updateTooltips, target, contextMenu); |
Member
There was a problem hiding this comment.
nit: I think we usually don't add contextMenu, it should work without it.
| items.get(2).hover(); | ||
| Assert.assertEquals("Item 2 / Tooltip", contextMenuTooltip.getText()); | ||
| Assert.assertEquals("top", | ||
| contextMenuTooltip.getDomProperty("_position")); |
Member
There was a problem hiding this comment.
I wonder if we could avoid checking the internal property. Not a blocker though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds Flow APIs for menu item tooltips, building on web-component support added in vaadin/web-components#11549.
A single
<vaadin-tooltip>is slotted into the menu/context-menu and auto-attached on first use, shared across root and sub-menu items. The menu-bar connector recurses through the item tree sotooltipandtooltipPositionreach nested items, which the web component's tooltip controller picks up.Warning
New tooltip-aware
addItemoverloads may make existing call sites ambiguous when anulllistener is passed with a cast, e.g.:Such call sites need to be updated to disambiguate the overload.
Fixes vaadin/web-components#10415
🤖 Generated with Claude Code