Skip to content

Core: OverlayChain::hover_anchored, the hover card primitive (B of #376) - #412

Merged
samitbasu merged 7 commits into
mainfrom
hover-376b
Nov 19, 2026
Merged

samitbasu merged 7 commits into
mainfrom
hover-376b

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Part of #376 (PR B of three). It is built on #410 (A), and its diff against main includes A's commit, so please review it after A. Against A it adds 14 files changed, 1034 insertions(+), 38 deletions(-).

The name is for you to pick

hover_anchored is the design note's placeholder (Q10). The alternatives were opened_by_hover and hover_intent.

API

b.overlay("card")
    .hover_anchored(trigger_id, HoverIntent::new(open, close).description(text))
    .placement(..)                 // still optional
    .children(|c| ..);
  • OverlayChain<Unplaced, Static>::hover_anchored(trigger: Id, intent: HoverIntent) -> OverlayChain<Floating, Animated> supplies both the anchor (Anchor::Node(trigger)) and shown.
  • overlay::HoverIntent { open: Duration, close: Duration, description: Option<String> } is #[non_exhaustive], built with new(open, close) and .description(text).
  • Builder::description_of(salt, body) -> Option<String> is new public API. It returns the text that body shows while accesskit is on, and None while it is off. It is the tooltip's existing path made public, so that the extras card (C) can describe its trigger. The design note had pointed at the internal text_of.
  • Problem::NestedHoverCard is new.

Behaviour

These follow the decisions on #376.

  • Opening. The pointer anywhere over the trigger (whole-control), or keyboard focus within it, opens the card after open. Focus also waits for open, and it does not move into the card (Focus::None). There is no skip-delay between cards.
  • The box counts as the trigger. While the card is open, its box and any overlay nested in it count as hovering the trigger, so the pointer can cross the gap. A press that started in the box and is still held keeps the card open. Once nothing holds it, the card closes after close.
  • Closing and the latch. Esc, a press outside, focus leaving and the window losing focus come from the existing dismiss.rs rules and are fed back to the machine as an interruption. A press on the trigger also closes the card, and the trigger's click still lands (Outside::PassThrough). After any of these, the card stays closed until the trigger is left, as a tooltip does.
  • Tab never stops in the card: its nodes are off the Tab order.
  • Touch never opens a card. This uses a per-viewport fact, kept internally, that the last pointer input was a touch.
  • Tooltips. The card replaces the tooltip of its trigger and of anything inside the trigger, by ancestry. A tooltip around the trigger yields while the card trigger is wanted for the same cause. Tooltips inside the card work as usual.
  • Accessibility. description is set on the trigger's focusable widgets, after the text of their own tooltips. The trigger gets no expanded/has_popup while the card is open, which matches Radix.
  • Nesting. A card declared inside another card is reported and never opens.
  • The card is Band::Popup. The doc of Band::Tooltip no longer mentions hover cards.

Behaviour changes: none for apps without hover cards. Where there is a card, the tooltips of and around its trigger yield to it, as decided.

Tests

tests/it/hover_anchored.rs has 15 tests that go through the full draw path. Each asserts its geometric preconditions. They cover:

  • the open delay;
  • crossing the gap into the box;
  • the close delay, and coming back within it;
  • a held press keeping the card open;
  • a button in the card taking a click;
  • a press on the trigger latching the card while its click lands;
  • Esc latching;
  • focus waiting for the delay, then Tab away closing the card;
  • Tab never stopping in the card;
  • the tooltips of and around the trigger yielding;
  • a tooltip inside the card showing;
  • touch never opening the card;
  • nesting being reported;
  • the description.

cargo xtask ci: exit 0.

🤖 Generated with Claude Code

…rt of #376)

The core primitive of the hover card (#376). `hover_anchored(trigger,
HoverIntent)` on an unplaced overlay chain supplies both the anchor (the
identified node `trigger`) and `shown`, which comes from a second
instance of the hover-intent machine (`Kept::hover_cards`), next to the
tooltips' own: one shared instance would close a card when a tooltip
inside it opens.

- `hover.rs` registers each declared card at build, and at the end of the
  draw, after dismissal is judged, resolves the triggers: the pointer over
  the trigger (whole-control), keyboard focus within it, and, while the
  card is open, the pointer over its box or an overlay nested in it, or a
  press that started there and is still held. The box counts as the
  trigger, so the pointer may cross the gap within the close delay.
- Dismissals of `dismiss.rs` (Esc, a press outside, focus leaving, blur)
  are fed back to the machine as an interruption, which latches the card
  closed until the trigger is left, as tooltips latch. A press on the
  trigger closes it too, and the press passes through (`PassThrough`).
- Focus waits for the open delay and never moves in (`Focus::None`); the
  card's nodes are off the Tab order.
- Touch never opens a card: a per-viewport "the last pointer input was a
  touch" fact beside `keyboard_was_last`.
- The card's trigger takes the tooltip slot of its subtree: tooltips of
  nodes inside it are dropped by ancestry, and one around it yields while
  the card trigger is wanted for the same cause. Tooltips inside the card
  work as usual.
- `HoverIntent::description` describes the trigger's focusable widgets
  to assistive technology, after their own tooltips' text.
- A card declared inside another card is reported as
  `Problem::NestedHoverCard` and never opens.

New public API: `OverlayChain::hover_anchored`, `overlay::HoverIntent`,
`Builder::description_of` (the text of a body while accesskit is on, the
tooltip's existing path made public for the extras' content), and
`Problem::NestedHoverCard`. The name `hover_anchored` is the design
note's placeholder, for the user to confirm.

`Band::Tooltip`'s doc no longer claims hover cards: they sense, so they
are `Band::Popup`.

Behaviour changes: none for tooltips without hover cards. With a card,
the tooltips of and around its trigger yield to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
@samitbasu

Copy link
Copy Markdown
Owner Author

Name confirmed by the user (2026-11-19): hover_anchored.

@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user after the hover-card trial (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit d488bb3 into main Nov 19, 2026
4 checks passed
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