From 3bcab0ecc1d73b74f5f4a1ab652c99df47221f30 Mon Sep 17 00:00:00 2001 From: Tom Edwards <109803929+TomEdwardsEnscape@users.noreply.github.com> Date: Mon, 15 Sep 2025 00:43:08 +0200 Subject: [PATCH] Fix tooltip hit test following a dirtyRect invalidation not respecting IsHitTestVisible (#19642) HitTester sees visuals with IsHitTestVisible=false unless you specifically filter them out! Added XML doc warning. --- src/Avalonia.Base/Rendering/IRenderer.cs | 11 +++++------ src/Avalonia.Controls/TopLevel.cs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Base/Rendering/IRenderer.cs b/src/Avalonia.Base/Rendering/IRenderer.cs index bd5aff8e6b..0ca4459c97 100644 --- a/src/Avalonia.Base/Rendering/IRenderer.cs +++ b/src/Avalonia.Base/Rendering/IRenderer.cs @@ -80,6 +80,10 @@ namespace Avalonia.Rendering /// /// Hit tests a location to find the visuals at the specified point. /// + /// + /// ⚠️ This method is low-level and DOES NOT respect . + /// Use to perform input hit testing, or provide your own function. + /// /// The point, in client coordinates. /// The root of the subtree to search. /// @@ -92,12 +96,7 @@ namespace Avalonia.Rendering /// /// Hit tests a location to find first visual at the specified point. /// - /// The point, in client coordinates. - /// The root of the subtree to search. - /// - /// A filter predicate. If the predicate returns false then the visual and all its - /// children will be excluded from the results. - /// + /// /// The visual at the specified point, topmost first. Visual? HitTestFirst(Point p, Visual root, Func? filter); } diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index 9d95ea5737..28449fa0b1 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -951,7 +951,7 @@ namespace Avalonia.Controls var clientPoint = this.PointToClient(lastPos); if (dirtyRect.Contains(clientPoint)) { - _tooltipService.Update(this, HitTester.HitTestFirst(clientPoint, this, null)); + _tooltipService.Update(this, this.InputHitTest(clientPoint, enabledElementsOnly: false) as Visual); } } }