From b65933b9d6b2cc88b541ea9ab5f911d85f3bd1bb Mon Sep 17 00:00:00 2001 From: Daniil Pavliuchyk Date: Thu, 2 Mar 2023 14:11:17 +0200 Subject: [PATCH] Update GetNameCore logic to match WPF logic --- .../Automation/Peers/LabelAutomationPeer.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs index 4ea950df7e..86cd0d5b14 100644 --- a/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/LabelAutomationPeer.cs @@ -19,9 +19,16 @@ namespace Avalonia.Controls.Automation.Peers return AutomationControlType.Text; } - override protected string GetNameCore() + override protected string? GetNameCore() { - return AccessText.RemoveAccessKeyMarker(((Label)Owner).Content as string) ?? string.Empty; + var content = ((Label)Owner).Content as string; + + if (string.IsNullOrEmpty(content)) + { + return base.GetNameCore(); + } + + return AccessText.RemoveAccessKeyMarker(content) ?? string.Empty; } } }