Repository navigation
Show tooltips with Floating UI and drop tippy.js - #4967
Conversation
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
…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]>
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]>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4967/ Sample changed pages: |
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]>
…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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
Tooltips now use the same Floating UI placement as every menu, and tippy.js and Popper v2 are gone, which makes
main.jsandds.jsabout 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 (
::afteron 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.tstooltip.tslistens on the document for any element with a non-emptydata-tooltipand shows its text in one sharedpopover="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 withdata-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.flashTooltipandinitTooltipskeep their signatures.Every producer moved to
data-tooltipThe API Razor partials,
chip-row.ts, the carousel and the one React file that set tippy attributes now writedata-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-themebecamedata-tooltip-theme.tippy.js removed
tippy.jsand@popperjs/coreleavepackage.jsonand 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:checkcould not run, becausevisual:seedtimes out onmainitself.journeys:testwas not run, and nothing was run against an assembled site.Verify
Bundle size, from clean builds of
mainand this branch, counting each entry's static imports (gzip, per file):main.js136,026 to 123,969 bytes andds.js142,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