Conversation
1f73ea3 to
468ec8b
Compare
f0f70d6 to
18f7a62
Compare
582faae to
0e83e53
Compare
11cb227 to
197a4ff
Compare
fa51e28 to
d771cbd
Compare
Menu items rendered via the `items` API can now show a tooltip on hover and keyboard focus by setting their `tooltip` property. A slotted `<vaadin-tooltip slot="tooltip">` element on the `<vaadin-context-menu>` or `<vaadin-menu-bar>` is required to render the tooltip; menu-bar sub-menu items reuse the same tooltip element as the root-level buttons so the hover and hide delays can be configured in a single place. Per-item `tooltipPosition` lets callers override where the tooltip opens relative to the item. Context-menu items and menu-bar sub-menu items default to `end`, items with a non-empty `children` array default to `start` so the tooltip doesn't overlap the opening sub-menu, and menu-bar root buttons fall back to the position configured on the slotted `<vaadin-tooltip>`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ab92199 to
312901b
Compare
- Move ContextMenuTooltipController setup into ContextMenuMixin so subclasses get tooltip support automatically. - Use `target._item` in ContextMenuTooltipController to read the item from rendered list-box children. - Close (not just untarget) the context-menu tooltip on overlay mouseleave. - In menu-bar, open hover tooltip for items with children when the sub-menu is closed, and force-close the tooltip when collapsing without focus restore.
a8a6821 to
07ffc75
Compare
Disabled items cannot open their sub-menu, so anchoring the tooltip at `start` leaves empty space where the sub-menu would have appeared. Treat disabled parents as leaf items and place the tooltip at `end`.
Document that sub-menu items default to `start`, all others (including disabled) default to `end`, and an explicit `position` on the slotted `<vaadin-tooltip>` overrides the per-item default.
|
|
|
||
| /** | ||
| * Controller for the tooltip slotted into a menu-like component (such as | ||
| * `<vaadin-context-menu>` or `<vaadin-menu-bar>`). Configures the tooltip |
There was a problem hiding this comment.
IMO, this could be placed in context-menu package for now.
| * @protected | ||
| */ | ||
| _getItem(_target) { | ||
| throw new Error('Must be implemented by subclass'); |
There was a problem hiding this comment.
I don't see a need for these errors, this is a private helper anyway. It's enough to add a comment // To be implemented. like we do elsewhere in the codebase.
| this._tooltipController.open({ trigger: 'hover' }); | ||
| }); | ||
|
|
||
| overlay.addEventListener('mouseleave', (event) => { |
There was a problem hiding this comment.
IMO these events could be added in a Lit template.
| ready() { | ||
| super.ready(); | ||
|
|
||
| this._tooltipController = this.parentElement._tooltipController; |
There was a problem hiding this comment.
This feels a bit confusing (we don't reuse controllers this way elsewhere), maybe could add a comment.
| <slot name="submenu" slot="submenu"></slot> | ||
| </vaadin-context-menu-overlay> | ||
|
|
||
| <slot name="tooltip"></slot> |
There was a problem hiding this comment.
Just realized that we don't have shadow DOM snapshot tests that would fail with this addition.
Please consider adding them in a separate PR so that this one would then be rebased.
| }); | ||
| /** @override */ | ||
| _getDefaultPosition(target) { | ||
| if (target.matches('vaadin-menu-bar-button')) { |
There was a problem hiding this comment.
nit: could use tagName check instead like we usually do in such cases.



Description
Fixes #10415
Adds optional tooltip support to
<vaadin-context-menu>and<vaadin-menu-bar>items rendered via theitemsAPI. Setting an item'stooltipproperty causes a slotted<vaadin-tooltip slot="tooltip">to open on hover and keyboard focus. The slotted tooltip is shared between root items and any nested sub-menus, so hover/hide delays, the generator, and the position can be configured in one place.Per-item position
bottom.startso the tooltip doesn't overlap the opening sub-menu.end.tooltipPositionproperty.positionset on the slotted<vaadin-tooltip>element always wins over per-item values.Disabled items
Combined with the
accessibleDisabledMenuItemsfeature flag from #11541, this is the primary motivation: disabled items can be hovered / focused and explain why they're unavailable via a tooltip.Type of change