Skip to content

tooltip: Keep a pressed trigger's tooltip dismissed until the pointer leaves - #3492

Merged
madcodelife merged 3 commits into
longbridge:mainfrom
alex-vas:fix/tooltip-click-removed-trigger
Oct 13, 2026
Merged

madcodelife merged 3 commits into
longbridge:mainfrom
alex-vas:fix/tooltip-click-removed-trigger

Conversation

@alex-vas

Copy link
Copy Markdown
Contributor

Problem

A managed tooltip (Button::tooltip and the other components that use ManagedTooltipExt) can stay on screen for good after a click removes its trigger, for example a button that replaces the view it sits in. Only another tooltip trigger can replace it.

Steps:

  1. Hover the button until its tooltip shows.
  2. Click it, with the pointer moving a pixel while the button is held and again right after the release. A trackpad or mouse does this on most clicks.

The mouse-down hides the tooltip, and the pointer stays on the button the whole time. GPUI reports hover as false while the button is held. The move right after the release is dispatched to the frame that was already drawn, where the button is still hovered, so on_hover(true) fires and the tooltip is requested again. The click has already removed the button, so the next frame doesn't contain it and no hover-leave ever follows. After the show delay, the tooltip appears at the button's old bounds and stays.

Fix

A press now keeps the trigger's tooltip dismissed until the pointer actually leaves the trigger, which is how native macOS and Windows controls behave. The trigger's bounds are recorded on mouse-down in the per-window WindowState. While they are recorded, a hover-enter on that trigger requests nothing. A hover-leave clears them only when the pointer is outside the trigger, because hover also reports false while the button is held.

The change is confined to crates/component (tooltip.rs, root.rs). gpui-base is untouched.

Public API

None. The new field on WindowState is pub(crate).

Tests

Two tests in crates/component/src/tooltip.rs:

  • clicking_a_trigger_away_does_not_leave_its_tooltip reproduces the bug. It dispatches the release and the move in one update so that no frame is drawn between them, as happens in a real event loop; the test platform otherwise draws a dirty window after every simulated event. It fails without the fix.
  • a_press_dismisses_the_tooltip_until_the_pointer_leaves: after a click on a trigger that stays, the tooltip doesn't come back while the pointer stays on it, and does come back after the pointer leaves and returns.

cargo test -p gpui-component --lib passes (667 tests), and cargo clippy -p gpui-component --all-targets -- --deny warnings and cargo fmt --check are clean.

Found in an application built on gpui-kit 0.6.6, where the bug was reproduced with real OS mouse events. The code is the same in 0.7.x and on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_019wKm1jXcvgRzuLoXfj1jMf

alex-vas and others added 3 commits October 13, 2026 22:33
… leaves

A trigger's mouse-down hid its tooltip, but the next hover-enter could
request it again while the pointer never left. When the click removes
the trigger (a button that replaces its view), a pointer move dispatched
before the next frame still hits the old frame, where the trigger is
hovered, so the tooltip was requested again. The trigger is gone from
the next frame, no hover-leave ever follows, and the tooltip appeared
after the show delay and stayed until another trigger replaced it.

A press now records the trigger's bounds in the window state, and the
trigger does not request its tooltip again until a hover-leave arrives
with the pointer outside it, matching native controls.

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

Copy link
Copy Markdown
Member

Thanks.

@madcodelife
madcodelife enabled auto-merge (squash) October 13, 2026 14:53
@madcodelife
madcodelife merged commit 7d7580f into longbridge:main Oct 13, 2026
13 of 15 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.

2 participants