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 #22488

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

SomeoneToIgnore
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore commented Dec 29, 2024

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

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 29, 2024
@SomeoneToIgnore SomeoneToIgnore added this pull request to the merge queue Dec 29, 2024
Merged via the queue into main with commit 344284e Dec 29, 2024
14 checks passed
@SomeoneToIgnore SomeoneToIgnore deleted the kb/fix-eternal-tooltips branch December 29, 2024 19:38
@SomeoneToIgnore
Copy link
Contributor Author

/cherry-pick v0.167.x

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Dec 29, 2024
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
SomeoneToIgnore added a commit that referenced this pull request Dec 29, 2024
…22488) (#22489)

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

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

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
SomeoneToIgnore added a commit that referenced this pull request Jan 1, 2025
@SomeoneToIgnore SomeoneToIgnore mentioned this pull request Jan 1, 2025
1 task
github-merge-queue bot pushed a commit that referenced this pull request Jan 1, 2025
…" (#22542)

This reverts commit 344284e.

That change broke git blame tooltips, as Zed should also show tooltips
which are hovered, even though the mouse had left the origin element's
bounds.

Release Notes:

- N/A
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Jan 1, 2025
…" (#22542)

This reverts commit 344284e.

That change broke git blame tooltips, as Zed should also show tooltips
which are hovered, even though the mouse had left the origin element's
bounds.

Release Notes:

- N/A
SomeoneToIgnore added a commit that referenced this pull request Jan 1, 2025
…" (cherry-pick #22542) (#22544)

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

This reverts commit 344284e.

That change broke git blame tooltips, as Zed should also show tooltips
which are hovered, even though the mouse had left the origin element's
bounds.

Release Notes:

- N/A

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
github-merge-queue bot pushed a commit that referenced this pull request Jan 1, 2025
Closes #21657

Follow-up of #22488
Previous PR broke git blame tooltips, which are expected to be open when
hovered, even if the mouse cursor is moved away from the actual blame
entry that caused the tooltip to appear.

Current version moves the invalidation logic into `prepaint_tooltip`,
where the new data about the tooltip origin is used to ensure we
invalidate only tooltips that have no mouse cursor in either origin
bounds or tooltip bounds (if it's hoverable).


Release Notes:

- Fixed tooltips getting stuck
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Jan 1, 2025
Closes #21657

Follow-up of #22488
Previous PR broke git blame tooltips, which are expected to be open when
hovered, even if the mouse cursor is moved away from the actual blame
entry that caused the tooltip to appear.

Current version moves the invalidation logic into `prepaint_tooltip`,
where the new data about the tooltip origin is used to ensure we
invalidate only tooltips that have no mouse cursor in either origin
bounds or tooltip bounds (if it's hoverable).


Release Notes:

- Fixed tooltips getting stuck
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Jan 1, 2025
Closes #21657

Follow-up of #22488
Previous PR broke git blame tooltips, which are expected to be open when
hovered, even if the mouse cursor is moved away from the actual blame
entry that caused the tooltip to appear.

Current version moves the invalidation logic into `prepaint_tooltip`,
where the new data about the tooltip origin is used to ensure we
invalidate only tooltips that have no mouse cursor in either origin
bounds or tooltip bounds (if it's hoverable).


Release Notes:

- Fixed tooltips getting stuck
helgemahrt pushed a commit to helgemahrt/zed that referenced this pull request Jan 1, 2025
…s#22488)

Closes zed-industries#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
SomeoneToIgnore added a commit that referenced this pull request Jan 1, 2025
Cherry-picked Remove stuck tooltips (#22548)

Closes #21657

Follow-up of #22488
Previous PR broke git blame tooltips, which are expected to be open when
hovered, even if the mouse cursor is moved away from the actual blame
entry that caused the tooltip to appear.

Current version moves the invalidation logic into `prepaint_tooltip`,
where the new data about the tooltip origin is used to ensure we
invalidate only tooltips that have no mouse cursor in either origin
bounds or tooltip bounds (if it's hoverable).


Release Notes:

- Fixed tooltips getting stuck

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
SomeoneToIgnore added a commit that referenced this pull request Jan 1, 2025
Cherry-picked Remove stuck tooltips (#22548)

Closes #21657

Follow-up of #22488
Previous PR broke git blame tooltips, which are expected to be open when
hovered, even if the mouse cursor is moved away from the actual blame
entry that caused the tooltip to appear.

Current version moves the invalidation logic into `prepaint_tooltip`,
where the new data about the tooltip origin is used to ensure we
invalidate only tooltips that have no mouse cursor in either origin
bounds or tooltip bounds (if it's hoverable).


Release Notes:

- Fixed tooltips getting stuck

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
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.

Tooltip stuck on screen
1 participant