Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate tooltips when mouse leaves element's hitbox (cherry-pick #22488) #22489

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

gcp-cherry-pick-bot[bot]
Copy link

Cherry-picked Invalidate tooltips when mouse leaves element's hitbox (#22488)

Closes #21657

In case of the task rerun button tooltip from

.group("term-tab-icon")
.child(
h_flex()
.group("term-tab-icon")
.child(
div()
.when(rerun_button.is_some(), |this| {
this.hover(|style| style.invisible().w_0())
})
.child(Icon::new(icon).color(icon_color)),
)
.when_some(rerun_button, |this, rerun_button| {
this.child(
div()
.absolute()
.visible_on_hover("term-tab-icon")
.child(rerun_button),
)
}),
)

, the actual button element is not styled as invisible, only its parent.
Zed won't render such element since it's parent is hidden, but will
consider it "visible" all the time its paint is called, spawning a
task with the delay, that will create the tooltip:

cx.background_executor().timer(TOOLTIP_DELAY).await;
cx.update(|cx| {
active_tooltip.borrow_mut().replace(ActiveTooltip {
tooltip: Some(AnyTooltip {
view: build_tooltip(cx),
mouse_position: cx.mouse_position(),
}),
_task: None,
});
cx.refresh();
})

When the parent is hidden, the child won't be painted anymore, and no
mouse listeners will be able to detect this fact and hide the tooltip.

Hence, check such cases separately, during prepaint, and invalidate
the tooltips that are not valid anymore.
We cannot use hitbox.is_hovered(cx) as it's not really hovered during
prepaint, so a mouse position check is used instead.

Release Notes:

  • Fixed tooltips getting stuck

Closes #21657

In case of the task rerun button tooltip from


https://github.com/zed-industries/zed/blob/f6dabadaf79bd29c89c8d55a1e9f1d33236f736e/crates/terminal_view/src/terminal_view.rs#L1051-L1070

, the actual button element is not styled as invisible, only its parent.
Zed won't render such element since it's parent is hidden, but will
consider it "visible" all the time its `paint` is called, spawning a
task with the delay, that will create the tooltip:


https://github.com/zed-industries/zed/blob/f6dabadaf79bd29c89c8d55a1e9f1d33236f736e/crates/gpui/src/elements/div.rs#L1949-L1959

When the parent is hidden, the child won't be painted anymore, and no
mouse listeners will be able to detect this fact and hide the tooltip.

Hence, check such cases separately, during `prepaint`, and invalidate
the tooltips that are not valid anymore.
We cannot use `hitbox.is_hovered(cx)` as it's not really hovered during
prepaint, so a mouse position check is used instead.

Release Notes:

- Fixed tooltips getting stuck
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 29, 2024
@SomeoneToIgnore SomeoneToIgnore merged commit b8ad3a5 into v0.167.x Dec 29, 2024
11 checks passed
@SomeoneToIgnore SomeoneToIgnore deleted the cherry-pick-7d61cd-v0.167.x branch December 29, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant