From ae82bc1b8f39362dbfec7412c2a5381a92998359 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 28 Jul 2023 11:19:57 +0200 Subject: [PATCH] Fix GetVisualRootCore. Needs to check for `IRootProvider`. Fixes integration tests on Windows. --- .../Automation/Peers/AutomationPeer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs index a264909ba6..fb7cdd87ed 100644 --- a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Avalonia.Automation.Provider; namespace Avalonia.Automation.Peers { @@ -254,17 +255,16 @@ namespace Avalonia.Automation.Peers protected virtual AutomationPeer? GetVisualRootCore() { - var parent = GetParent(); + var peer = this; + var parent = peer.GetParent(); - while (parent != null) + while (peer.GetProvider() is null && parent is not null) { - var nextParent = parent.GetParent(); - if (nextParent == null) - return parent; - parent = nextParent; + peer = parent; + parent = peer.GetParent(); } - return null; + return peer; }