[render preview] [Feature] Remove Popper.js — port hover_card & context_menu to Floating UI (#158)
Closes #158.
What & why
tippy.js (which bundles @popperjs/core) was the last dependency pulling Popper into RubyUI, and the source of the importmap install issues described in #158. The other nine positioned components already use @floating-ui/dom; this ports the final two — HoverCard and ContextMenu — and removes Popper/tippy from the gem and the docs site entirely.
Changes
Gem (gem/)
- Rewrote
hover_card_controller.jsandcontext_menu_controller.json@floating-ui/dom(computePosition+autoUpdate,flip/shift/offset), dropping tippy. Keyboard nav,matchWidth, hover open/close delays, right-click trigger, outside-click + Escape close are all preserved. hover_card_content.rb/context_menu_content.rbnow render a real hidden, absolutely-positioneddivinstead of a cloned<template>(Floating UI positions a live element rather than cloning markup).dependencies.yml: hover_card & context_menu now map to@floating-ui/dom.javascript_utils.rb: removedpin_tippy_js(the tippy +@popperjs/coreCDN importmap pins).package.json: removedtippy.js.
Docs (docs/)
- Synced both Stimulus controllers.
- Removed
tippy.jsfrompackage.json+pnpm-lock.yaml. - Removed the tippy/popper importmap install snippet in
component_setup/manual_steps.rb.
Tests
- New assertions that content renders a hidden positioned
div, not a<template>. Full suite green (239 runs, 0 failures), StandardRB clean.
Impact on apps using these components
Components are copy-and-paste, so existing installs keep working until regenerated. Apps that update HoverCard/ContextMenu must repin their importmap (drop tippy.js + @popperjs/core, add @floating-ui/dom) and recopy the controller. The Ruby/markup API is unchanged. Note: the popup now opens below the trigger by default (with flip()), where tippy defaulted to above — same content, standard RubyUI placement.
Manual test instructions
Run the docs site (or any app with these components) and verify:
Hover Card — /docs/hover_card
- Hover the
@joeldrappertrigger → card appears (after a short delay) with avatar, bio, joined date. - Move the mouse off → card hides after a short delay.
- Move from trigger onto the card → stays open.
- Scroll/resize the window while open → card stays anchored (autoUpdate).
Context Menu — /docs/context_menu
- Right-click "Right click here" → the custom menu opens; the native browser menu does NOT appear.
- "Forward" is disabled; "Show Bookmarks Bar" shows a checkmark.
- Click any item → menu closes.
- Click outside the menu → it closes. Press Escape → it closes.
Regression check: confirm no console errors, and that the other Floating UI components (Popover, Tooltip, Dropdown Menu, Select, Combobox) still behave normally.
Before/after screenshots (tippy → Floating UI) were captured during development for both components — content is identical; HoverCard now opens below the trigger and ContextMenu flips to fit the viewport.
Summary by cubic
Replaced tippy.js/@popperjs/core with @floating-ui/dom for HoverCard and ContextMenu to remove Popper and resolve importmap install issues in #158. Content now renders as a hidden, absolutely positioned div and is positioned with computePosition + autoUpdate.
-
Bug Fixes
- HoverCard: Escape now closes; focusing into the card (
focusin/focusout) keeps it open. - ContextMenu: Close on outside right‑click (
contextmenu) as well as click. - Both: Set initial
data-state="closed"and keep it in sync with thehiddenclass so enter/exit animations play correctly. - Rebuilt
mcp/data/registry.jsonto reflect the Floating UI migration and satisfy the CI registry check.
- HoverCard: Escape now closes; focusing into the card (
-
Migration
- No Ruby/markup API changes.
- If updating: remove
tippy.jsand@popperjs/corepins, add@floating-ui/dom, and recopy the controllers. Default placement opens below the trigger (with flip), where tippy defaulted to above.