Skip to content

[Bug Fix] HoverCard: let the card escape a clipping ancestor - #530

Open
leonardo-vsilva wants to merge 2 commits into
ruby-ui:mainfrom
leonardo-vsilva:fix/hover-card-fixed-strategy
Open

[Bug Fix] HoverCard: let the card escape a clipping ancestor#530
leonardo-vsilva wants to merge 2 commits into
ruby-ui:mainfrom
leonardo-vsilva:fix/hover-card-fixed-strategy

Conversation

@leonardo-vsilva

@leonardo-vsilva leonardo-vsilva commented Sep 10, 2026

Copy link
Copy Markdown

Related issue

No existing issue — happy to open one if you'd prefer to track it there.

Description

HoverCardContent is position: absolute, so a positioned ancestor that hides its overflow — a scroll area, a table cell, a truncating container — clips the card instead of letting it overflow.

DropdownMenu already solves this: the root switches between is-absolute and is-fixed from options[:strategy], the content picks up its position through a group variant, and the controller passes the strategy on to computePosition. This gives HoverCard the same escape hatch, following that implementation exactly:

  • HoverCard root gains group/hover-card plus is-absolute / is-fixed;
  • HoverCardContent trades its hardcoded absolute for group-[.is-absolute]/hover-card:absolute group-[.is-fixed]/hover-card:fixed;
  • the controller passes strategy: this.optionsValue.strategy || "absolute" to computePosition.

The default stays absolute, so existing usage renders and positions exactly as before.

Docs get an "Escaping a clipping ancestor" example, and mcp/data/registry.json is rebuilt (cd mcp && bundle exec rake mcp:build) so mcp-registry-check stays green.

Before After
image image

Testing instructions

  1. cd gem && bundle exec rake — 292 runs, 0 failures; standardrb clean across 402 files.
  2. cd docs && bin/dev, open /docs/hover_card and scroll to Escaping a clipping ancestor. Hover @joeldrapper: the card renders in full, overflowing the relative … overflow-hidden container around it.
  3. Revert that example to the default strategy (drop option: {strategy: "fixed"}) and hover again: the card is clipped by the container — the behaviour on main today.
  4. Every other HoverCard on the docs site still opens and positions as before, since the default is unchanged.

Summary by cubic

Fixes HoverCardContent being clipped by ancestors with overflow: hidden. HoverCard now supports option: {strategy: "fixed"} to position the card against the viewport instead; the default remains absolute, so existing usage is unchanged.

  • Mirrors DropdownMenu: the root switches between is-absolute and is-fixed, the content picks up its position through a group variant, and the controller passes the strategy to computePosition.
  • Adds an "Escaping a clipping ancestor" docs example and rebuilds mcp/data/registry.json.
  • Also fixes DropdownMenu's strategy ternary so unsupported values fall back to absolute like Floating UI, preventing a fixed card from drifting on scroll.

Written for commit 28ac6ec. Summary will update on new commits.

Review in cubic

HoverCardContent is `position: absolute`, so an ancestor with
`overflow: hidden` — a scroll area, a table cell, a truncating
container — clips the card instead of letting it overflow.

Give HoverCard the same escape hatch DropdownMenu already has:
`option: {strategy: "fixed"}` switches the root to `is-fixed`, the
content picks up `fixed` through the group variant, and the controller
passes the strategy on to computePosition. The default stays
`absolute`, so existing usage is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread mcp/data/registry.json Outdated
The class ternary keyed off "absolute", so every other value — a typo
like "absolut" included — rendered `is-fixed`, while Floating UI keys
off "fixed" and computes anything else as absolute. The card then
painted `position: fixed` with coordinates resolved against its offset
parent, drifting from the trigger on scroll.

Key the class off "fixed" instead, so both sides fall back to absolute
on the same input. DropdownMenu carried the same ternary; fix both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cirdes
cirdes requested review from djalmaaraujo and removed request for cirdes September 10, 2026 17:26
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.

1 participant