Tooltip completeness (pre-migration) — design
Date: 2026-12-01
Branch: tooltip-component
Status: approved for implementation
Goal
Make ui5-tooltip + its document-level delegation feature-complete and shippable
before any component migrates to it. The demo page must work with plain HTML
elements only (plain <button>, headings, <a>) so the tooltip can be reviewed and
merged independently; full component migration is a later PR.
Requirements (from tooltips-todo-12-01.md)
- The tooltip text must be hoverable and selectable (move onto the bubble, select text).
- The opener's own text must also stay selectable (tooltip must not steal it).
- When text is too large / the screen too small, the bubble must truncate/wrap/scroll within the space it has, never overflow the viewport.
- Expand the standalone demo page to cover buttons, titles, links, long text, all placements, and mobile — working without migrated components.
- Mobile:
- Links opt out of the tooltip (native link menu wins) via a property.
- Trigger by long-press.
- Text on the opener remains selectable before selection/long-press fires.
- Tooltip text is selectable after the tooltip is shown.
Non-goals
- Migrating
ui5-button/ui5-link/etc. to the new tooltip (separate PR). - Porting the entire OpenUI5 demo verbatim (we expand our own
Tooltip.html).
Architecture
The feature lives in three files, unchanged in their responsibilities:
packages/main/src/TooltipDelegation.ts— document-level gesture delegation (hover / focus / long-press → open/close), module-global state.packages/main/src/Tooltip.ts— theui5-tooltipcustom element (public API, popover host, registry membership).packages/main/src/themes/Tooltip.css— bubble styling.
1. Interaction model: the hover-bridge
Today the popover is pointer-events: none and onMouseOut closes on any leave of the
opener (with a rect guard that ignores the spurious top-layer mouseout). To make the
bubble hoverable/selectable, the opener + its own tooltip popover become one hover
region:
.ui5-tooltip-popover→pointer-events: auto;.ui5-tooltip-text→user-select: text.onMouseOut: keep open when the pointer is still on the opener (existing rect guard) OR the mouseout destination is within this tooltip's own popover.onMouseOver: a mouseover whose composed path includes the tooltip's popover cancels that tooltip's pending close (opener → bubble keeps it open).- Close fires only when the pointer leaves both opener and popover.
- The spurious-top-layer-mouseout rect guard (already shipped) stays — the popover still promotes to the top layer.
ITooltipTarget gains a predicate to test whether a node belongs to the tooltip
(so the delegation can recognise "pointer is over this tooltip's bubble"). The Tooltip
implements it by checking the composed ancestry against its own shadow popover / host.
2. Truncation / small screens
.ui5-tooltip-text:
max-width: min(17rem, calc(100vw - 2rem))— never wider than the viewport.overflow-wrap: break-word(already present) — long unbroken words wrap.max-height: calc(100vh - 2rem); overflow: auto— extreme text scrolls inside the bubble instead of overflowing the screen.
Popover placement flipping (inherited from ui5-popover) keeps the bubble on-screen;
the text wraps/scrolls within.
3. Mobile
- Long-press trigger already exists (
LONG_PRESS_MS); kept. The long-press timer must not pre-empt native text selection on the opener before it fires, and the shown bubble is selectable (hover-bridge +user-select: text,pointer-events: auto). - Link opt-out: new public boolean property
preventOnTouchonui5-tooltip(attributeprevent-on-touch, defaultfalse). When set,onTouchStartdoes not arm the long-press for that tooltip, so the opener's native menu wins. Surfaced to the delegation viaITooltipTarget.
4. Demo page — packages/main/test/pages/Tooltip.html
Standalone, plain elements only. Each opener: data-ui5-has-tooltip + aria-describedby
- a sibling
<ui5-tooltip>. Cases:
- plain
<button>(Top) - heading / title text (selectable title + selectable tooltip)
<a href>link withprevent-on-touch- long-text opener (truncation / wrap / scroll)
- one opener per placement: Top, Bottom, Left, Right, and horizontal-align Start/End
- short note on mobile testing (long-press, link opt-out)
Plus website samples under docs/_samples/main/Tooltip/ (Basic + Placements), with
sample.html, main.js, and <Name>.md per the repo sample convention.
5. Testing (production-workflow contract)
Cypress component tests (packages/main/cypress/specs/Tooltip.cy.tsx), asserting
observable/public behaviour only:
- tooltip text is selectable (
user-selectcomputedtext; popoverpointer-eventscomputedauto). - hover-bridge: opener → bubble keeps it open; leaving both closes; second hover reopens
(assert synchronously via
isOpen()aftercy.tick, not retrying attribute checks). - truncation:
.ui5-tooltip-textmax-widthnever exceeds viewport width. prevent-on-touch: atouchstarton the opener does not open the tooltip; without it, long-press (timer) opens.- existing specs stay green.
Manual mutation check on new branches (bridge predicate true/false, preventOnTouch
true/false). Visual spec re-run. Real-browser verification on desktop; mobile verified by
the user via the LAN URL (http://<host-lan-ip>:8080/...).
Risks / notes
cy.clockfake timers are needed for the long-press/hover-delay timing.TooltipDelegationhas module-global state that leaks acrosscy.mountin a spec — tests must be written to tolerate / reset it (and verified with.onlyin isolation).- Playwright
mouse.movefeeds stale coords on the top-layer mouseout; the deterministic reproduction of hover-bridge edge cases lives in Cypress.