[render preview] [Feature] Remove Popper.js — port hover_card & context_menu to Floating UI (#158)#438
Merged
Merged
Conversation
…ng UI (#158) tippy.js (which bundles @popperjs/core) was the last dependency pulling Popper into RubyUI and breaking importmap installs. The other nine components already use @floating-ui/dom; this ports the final two. Gem: - Rewrite hover_card & context_menu Stimulus controllers on @floating-ui/dom (computePosition + autoUpdate, flip/shift/offset), dropping tippy. - Content components now render a real hidden, absolutely-positioned div instead of a cloned <template> (Floating UI positions a live element). - dependencies.yml: hover_card/context_menu -> @floating-ui/dom. - javascript_utils.rb: drop pin_tippy_js (tippy + @popperjs/core CDN pins). - package.json: drop tippy.js. Docs: - Sync both controllers, drop tippy.js from package.json + lockfile, remove the tippy/popper importmap install snippet. Tests: - Assert content renders a hidden positioned div, not a <template>.
There was a problem hiding this comment.
4 issues found across 14 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="gem/lib/ruby_ui/context_menu/context_menu_content.rb">
<violation number="1" location="gem/lib/ruby_ui/context_menu/context_menu_content.rb:18">
P2: Hardcoded `data_state: "open"` and `data-[state=closed]:...` CSS classes are inconsistent with controller behavior: the JavaScript controller toggles the `hidden` class but never updates `data-state`, making all closed-state animation classes unreachable and leaving semantic state stale.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Collaborator
|
@djalmaaraujo, please take a look on cubic issues! |
Fixes from PR review (cubic): - hover_card: Escape now closes the card. Was gated behind an early return for the no-menu-items case, making it unreachable for the common hover-card usage. - hover_card: add focusin/focusout listeners to the content element so moving keyboard focus into the card no longer auto-closes it. - context_menu: dismiss on outside right-click (contextmenu), not just left-click, so the native menu can take over instead of leaving a stale menu open. - both: controllers now toggle data-state open/closed in sync with the hidden class, keeping semantic state and state-based animation classes accurate instead of permanently "open".
CI 'MCP registry up to date' check rebuilds registry.json from ../gem and fails on diff. Regenerated so hover_card/context_menu reflect @floating-ui/dom (not tippy.js) and the updated component sources.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
cubic flagged HoverCardContent rendering data-state=open while hidden, which left the enter animation classes active before first show and made semantic state inconsistent. Initial state is now 'closed' (matches the hidden class); the controllers flip it to 'open' on show, so the data-[state=open] enter animation actually plays on reveal. Applied to both hover_card and context_menu content; registry.json regenerated.
cirdes
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/)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/)tippy.jsfrompackage.json+pnpm-lock.yaml.component_setup/manual_steps.rb.Tests
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 (withflip()), 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@joeldrappertrigger → card appears (after a short delay) with avatar, bio, joined date.Context Menu —
/docs/context_menuRegression check: confirm no console errors, and that the other Floating UI components (Popover, Tooltip, Dropdown Menu, Select, Combobox) still behave normally.
Summary by cubic
Replaced
tippy.js/@popperjs/corewith@floating-ui/domfor 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 withcomputePosition+autoUpdate.Bug Fixes
focusin/focusout) keeps it open.contextmenu) as well as click.data-state="closed"and keep it in sync with thehiddenclass so enter/exit animations play correctly.mcp/data/registry.jsonto reflect the Floating UI migration and satisfy the CI registry check.Migration
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.Written for commit 55f882a. Summary will update on new commits.