Skip to content

feat(ui5-tooltip): add enhanced visual tooltip component - #14248

Draft
alexandar-mitsev wants to merge 9 commits into
mainfrom
tooltip-component
Draft

alexandar-mitsev wants to merge 9 commits into
mainfrom
tooltip-component

Conversation

@alexandar-mitsev

@alexandar-mitsev alexandar-mitsev commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a new enhanced ui5-tooltip web component — a visual, SAP Fiori–styled tooltip that wraps the popover and supersedes the native title attribute.

What's included

  • New Tooltip component Tooltip.ts.
  • A data-ui5-has-tooltip attribute which connects the invoker to the tooltip.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Sample sync reminder

HTML sample changed but React sample (sample.tsx) not updated:

  • main/Tooltip/Basic
  • main/Tooltip/Placements

Please keep both samples in sync, or ignore if the change does not apply to both.

@sap-ui5-webcomponents-release

Copy link
Copy Markdown

@alexandar-mitsev
alexandar-mitsev marked this pull request as draft November 2, 2026 10:06
Introduce `<ui5-tooltip>`, a framework-agnostic visual tooltip that an
element opts into via `data-ui5-has-tooltip="<id>"` (gestures) and
`aria-describedby="<id>"` (accessible description). The host is a manual
popover (UA `display:none` when closed, top layer when shown) that wraps an
inner `ui5-popover` for the bubble; opening is delegated through shared
document-level listeners resolving openers via `event.composedPath()`.

Migrate existing title-based tooltips (Button, Link, Switch, Icon,
RatingIndicator, SegmentedButtonItem, ColorPaletteItem, FileUploader,
Breadcrumbs, Carousel, AvatarBadge, Title, InputIcon) to the new component,
preserving each component's accessibility wiring (aria-description /
aria-label as appropriate; no double-announcement).

Includes Cypress specs (unit, delegation, visual), test pages, and website
samples.
Update badge-tooltip assertions to check the delegated
aria-label and data-ui5-has-tooltip on the icon root instead
of the native title attribute, matching the tooltip delegation
model.
Tabbing onto an opener opened its tooltip, but the next Tab bounced
focus back to the opener. The tooltip renders into a ui5-popover, and
two mechanisms in the shared Popup kept focus on the opener:

- the popover's focus-trap sentinels (first-fe/last-fe) sit in the tab
  order, and the empty trap forwards focus back to the root; and
- closePopup restores focus to the element focused before opening (the
  opener) when the tooltip closes on tab-out.

A tooltip is non-interactive, so it must stay out of the tab order and
never restore focus. Gate the trap sentinels behind a new private
Popup.preventFocusTrap flag and set it, together with the existing
preventFocusRestore, on the tooltip's popover. Also mark Tooltip._open
noAttribute so the private flag stops leaking an _open attribute.
Opening the tooltip promotes its popover to the top layer, which makes the
browser re-hit-test and fire a mouseout on the still-hovered opener even
though the pointer never moved. The delegation treated that stray mouseout
as a leave and scheduled a close, producing an open/close flicker that could
leave the tooltip stuck closed on the next hover.

onMouseOut now ignores a mouseout whose coordinates still fall within the
opener's box (rect containment is reliable where relatedTarget and
elementFromPoint are not). The tooltip popover is also set pointer-events:none
so it never perturbs the opener's hover hit-testing.
…-out

- Make the tooltip bubble pointer-interactive and its text selectable; the
  delegation bridges the opener and its bubble as one hover region so moving
  onto the bubble keeps it open (and does not flicker or get stuck closed).
- Clamp the text to the viewport (max-width min(17rem, 100vw - 2rem), capped
  height with scroll) so long text never overflows a small screen.
- Add a public preventOnTouch property so openers like links keep their native
  touch menu instead of opening the tooltip on long-press.
- Expand the standalone demo page (plain elements only: buttons, title, link,
  long text, all placements) and add Basic/Placements website samples.
Cap the tooltip text to the viewport and to a line count, clipping the
overflow with an ellipsis (overflow:hidden + line-clamp) rather than making
the bubble scroll. Add demo cases (long text, huge multi-paragraph text,
unbreakable word) and a regression test asserting the text does not scroll
and stays within the viewport.
Mirror OpenUI5's TooltipEventTrigger behavior:
- Do not dismiss the tooltip on a mousedown inside its bubble, nor when a text
  selection is anchored in the opener or bubble, so desktop copy-from-tooltip
  works and selecting text does not open/close the tooltip.
- On touch, suppress native text selection / iOS callout on the opener so a
  long-press opens the tooltip; openers that opt out of touch keep their native
  menu, and the context menu is blocked for text openers but allowed for them.
- Apply the touch suppression as inline styles on the opener (saved/restored)
  rather than a global CSS class, so it works for an opener in any root -
  light DOM or deep in a shadow root.
- Rework the demo page: distinct button/title/link styling and an activation
  toast so activation is distinguishable from the tooltip.

This branch was previously deployed

1 inactive deployment
netlify-preview — b737584c Deployed Dec 1, 2026 by alexandar-mitsev via deploy-preview #3913
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.

2 participants