diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index a20ad90c1fcea84942778e8eed1b8668e5f332e9..fd313213c360bd43b6d3fc3d1f37249f03e50116 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -1552,19 +1552,6 @@ impl<'a> WindowContext<'a> { let tooltip_size = element.layout_as_root(AvailableSpace::min_size(), self); let mut tooltip_bounds = Bounds::new(mouse_position + point(px(1.), px(1.)), tooltip_size); - // Element's parent can get hidden (e.g. via the `visible_on_hover` method), - // and element's `paint` won't be called (ergo, mouse listeners also won't be active) to detect that the tooltip has to be removed. - // Ensure it's not stuck around in such cases. - let invalidate_tooltip = !tooltip_request - .tooltip - .origin_bounds - .contains(&self.mouse_position()) - && (!tooltip_request.tooltip.hoverable - || !tooltip_bounds.contains(&self.mouse_position())); - if invalidate_tooltip { - return None; - } - let window_bounds = Bounds { origin: Point::default(), size: self.viewport_size(), @@ -1594,6 +1581,19 @@ impl<'a> WindowContext<'a> { } } + // Element's parent can get hidden (e.g. via the `visible_on_hover` method), + // and element's `paint` won't be called (ergo, mouse listeners also won't be active) to detect that the tooltip has to be removed. + // Ensure it's not stuck around in such cases. + let invalidate_tooltip = !tooltip_request + .tooltip + .origin_bounds + .contains(&self.mouse_position()) + && (!tooltip_request.tooltip.hoverable + || !tooltip_bounds.contains(&self.mouse_position())); + if invalidate_tooltip { + return None; + } + self.with_absolute_element_offset(tooltip_bounds.origin, |cx| element.prepaint(cx)); self.window.tooltip_bounds = Some(TooltipBounds {