Skip to content

Show tooltips with Floating UI and drop tippy.js - #4967

Merged
reakaleek merged 20 commits into
mainfrom
floating-tooltips
Nov 19, 2026
Merged

reakaleek merged 20 commits into
mainfrom
floating-tooltips

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Tooltips now use the same Floating UI placement as every menu, and tippy.js and Popper v2 are gone, which makes main.js and ds.js about 12 kB smaller gzipped.

Affects: Site UI, API reference

Prompt summary: Everything that floats in the docs UI should be placed by Floating UI through one shared implementation. Tooltips were the last place using a second library, tippy.js, which brings in Popper. This PR replaces them and deletes the dependency.

Why

The site placed floating elements in several ways. Tooltips used tippy.js, which pulls in Popper v2 next to the Floating UI that menus already use. Three more tooltip styles were plain CSS (::after on the CLI badges, the copy button, and the design-system tooltip), each with its own look. On the design-system bundle, tippy ran but its stylesheet was never loaded, so those tooltips had no styling at all.

What

One tooltip, built on floating.ts

tooltip.ts listens on the document for any element with a non-empty data-tooltip and shows its text in one shared popover="manual" element. A manual popover sits in the top layer, so it shows above an open modal dialog and never closes an open menu. It appears after 80ms on hover (500ms with data-tooltip-delay="slow"), at once on keyboard focus, and after a 300ms touch hold. Escape or a click puts it away until the pointer leaves. flashTooltip and initTooltips keep their signatures.

Every producer moved to data-tooltip

The API Razor partials, chip-row.ts, the carousel and the one React file that set tippy attributes now write data-tooltip. The CLI badges, the copy button and the design-system tooltip primitive use the same attribute, so there is one system and one look in both bundles. data-tippy-theme became data-tooltip-theme.

tippy.js removed

tippy.js and @popperjs/core leave package.json and the lockfile, along with the tippy stylesheet import and every .tippy-* rule.

Tradeoffs: in a browser without the Popover API, tooltips do not show. The CLI badges and the copy button used to have CSS tooltips there. The copy button's tooltip now shows above it after 80ms, where it showed to its left after 0.5s.

Not verified: visual:check could not run, because visual:seed times out on main itself. journeys:test was not run, and nothing was run against an assembled site.

Verify

mise run site:test
mise run test
mise run serve   # hover an endpoint copy button on an API operation page, click it, then press Escape

Bundle size, from clean builds of main and this branch, counting each entry's static imports (gzip, per file): main.js 136,026 to 123,969 bytes and ds.js 142,935 to 130,899 bytes. The drop is the deleted tippy and Popper chunk, less about 3 kB for the new code. It excludes lazily loaded chunks and brotli transfer size.

Check on the preview

  • Elasticsearch search operation — hover the copy button next to the path: a dark tooltip shows "Copy", and "Copied!" after a click.
  • Images — control: a page with no data-tooltip targets must look unchanged.

reakaleek and others added 5 commits November 19, 2026 22:42
The tooltip reuses the menus' placement code. place() now resolves with where the element went, since flip can move it below its anchor and the tooltip's arrow has to follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tooltips now go through floating.ts like every other floating element, and tippy.js and Popper v2 leave the bundle. One delegated listener set and one shared manual popover cover every [data-tooltip], on every page of both bundles. A manual popover sits in the top layer above an open modal dialog, so tippy's appendTo-the-dialog workaround goes away, and it never closes an open menu.

data-tooltip was already the attribute of the CSS-only tooltips (CLI modifier badges, the code copy button), so those move onto the shared tooltip and their ::after CSS goes, as does the design system Tooltip primitive's own bubble. One tooltip system remains.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A copy button swaps its icon under a resting pointer, which fires a fresh pointerover inside the same target, so a tooltip put away with Escape or a click came straight back. It now stays away until the pointer leaves, as a mouseenter-based tooltip did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 19, 2026 21:56
@reakaleek
reakaleek requested a review from akira28 November 19, 2026 21:56
reakaleek and others added 4 commits November 19, 2026 23:02
The tooltip used #333 and #fff, so it stayed dark grey in every theme. It now reads --color-emphasis and --color-on-emphasis, as the DS tooltip did. The token test now scans Assets/tooltip.css, which it skipped before.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…by Libra)

A chip that resizes until its title fits drops data-tooltip, but its tooltip stayed until the pointer left. The tracking callback now checks that the target still matches the tooltip selector.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ibra)

The focus handler returned when the pointer had already queued a tooltip for the same control, so the keyboard user waited out the hover delay. Only an already visible tooltip is skipped now.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Escape on a tooltip that keyboard focus opened marked the target dismissed, and only a pointerout clears that. The pointer had never entered, so the first hover showed nothing. The handler now tracks the hovered target and dismisses only when the pointer is on it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
reakaleek and others added 2 commits November 19, 2026 23:08
…ew by Libra)

With NAVIGATION_PREVIEW off, styles.css loads tooltip.css without the theme that defines --color-emphasis, so the tooltip was transparent. It now falls back to --color-grey-130 and --color-white, which the legacy theme emits.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…eview by Libra)

Escape on a chip's tooltip while the pointer sat on the count inside it matched only the exact hovered element, so moving from the count to the chip reopened the tooltip. Escape now dismisses when the hovered target is the chip or any target nested in it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…eview by Libra)

The isolated site loads styles.css unless the navigation preview flag is on, so it exercises the fallback tokens. The test moves a real pointer over the copy button and reads the computed colours of the tooltip and its arrow. A journey file can read computed styles but not assert on one, so this is a C# test, like ApiExampleScrollingTests.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
reakaleek and others added 3 commits November 19, 2026 23:22
The journeys workflow requires every test class to be in exactly one shard, so the unlisted class failed the plan job before any browser journey ran. The test opens a docs page and waits on no API spec, so it joins the site shard.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…w by Libra)

Chrome can serialise a translucent colour as oklab(... / 0.5) or color(srgb ... / 0.5), which the rgba() prefix check read as opaque. Each colour now goes through a canvas pixel, which gives sRGB bytes with an exact alpha whatever the syntax.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… by Libra)

Comparing the two colour strings passed for a text colour almost identical to the background. The test now computes the WCAG contrast of the text, blended over the background, and requires 4.5:1, the AA level for normal-size text. The label is formatted with the invariant culture, so a comma-decimal locale does not print 4,5.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

reakaleek and others added 2 commits November 19, 2026 23:38
Takes main's section-links row whole: it drops the back-to-top button my branch had renamed to data-tooltip, and replaces initSectionLinksStuck. api-docs.ts calls neither initSectionLinksStuck nor initTooltips, since the tooltip starts from the global init. place() keeps main's boundary parameter and returns the position for the tooltip.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…y (per review by Libra)

The colours were read the moment the tooltip was placed, while its opacity transition was still running, and the popover's own opacity was never checked. A tooltip that settled at opacity 0.2 passed every assertion. The test now waits for the tooltip's animations to finish and asserts it ends fully opaque.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
reakaleek and others added 2 commits November 19, 2026 23:45
…by Libra)

The focus handler asked the data-tooltip ancestor whether it matched :focus-visible, so tabbing to a link inside a target, such as the optional endpoint segment, showed nothing. It now asks the element that took focus.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…Libra)

The tooltip ignored the pointer and closed as soon as it left the trigger, which fails the hoverable requirement of WCAG 1.4.13 and makes long text hard to read with a magnifier. A mouse leaving the trigger now has 150ms to reach the tooltip, and a pointer on it keeps it open. A touch, which cannot reach it, still closes at once, and a click inside the tooltip no longer dismisses it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
return
}
cancelClose()
closeTimer = window.setTimeout(hide, CLOSE_GRACE_MS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Moving the mouse off a trigger closes its tooltip after 150 ms even if the trigger still has keyboard focus. With both inputs in use, a user can lose the hint without moving focus and cannot recover it from the keyboard without tabbing away and back. Keep the tooltip open while keyboard focus remains in the trigger.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c192733 — the grace timer that closed the tooltip under a focused trigger is gone with the revert of the hoverable change. A tooltip that keyboard focus opened now closes only on focusout, Escape or a click, and pointerout closes it at once as before that change. #4970 tracks hoverability and lists this case.

This reverts commit a9b5607.

A tooltip that takes pointer events covers the row above its trigger in stacked lists and swallows clicks meant for it. It also closed under a focused trigger and lost text selections. The tooltip goes back to the behaviour of the tippy tooltips it replaces, and the hoverable design is tracked in #4970.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@reakaleek
reakaleek merged commit f8a0f0b into main Nov 19, 2026
44 checks passed
@reakaleek
reakaleek deleted the floating-tooltips branch November 19, 2026 23:24
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.

1 participant