From c7db3bfee7973aeb2adf121e1212b845454e237c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 20 May 2023 16:06:25 +0200 Subject: [PATCH 1/2] Added failing test for #11370. --- samples/IntegrationTestApp/MainWindow.axaml | 3 +++ tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index d8d9678a2d..1c88f2c95f 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -47,6 +47,9 @@ + diff --git a/tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs b/tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs index c0a5414ee3..fc2325b29e 100644 --- a/tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs +++ b/tests/Avalonia.IntegrationTests.Appium/ButtonTests.cs @@ -27,6 +27,15 @@ namespace Avalonia.IntegrationTests.Appium Assert.False(button.Enabled); } + [Fact] + public void EffectivelyDisabledButton() + { + var button = _session.FindElementByAccessibilityId("EffectivelyDisabledButton"); + + Assert.Equal("Effectively Disabled Button", button.Text); + Assert.False(button.Enabled); + } + [Fact] public void BasicButton() { From 65b3de61621756f115a865ab958cd4cc0f34a51e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 20 May 2023 16:08:08 +0200 Subject: [PATCH 2/2] Use `IsEffectivelyEnabled` in automation peers. Fixes #11370 --- src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs index d04dfec3e8..c55bd0f3e5 100644 --- a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs @@ -151,7 +151,7 @@ namespace Avalonia.Automation.Peers protected override bool HasKeyboardFocusCore() => Owner.IsFocused; protected override bool IsContentElementCore() => true; protected override bool IsControlElementCore() => true; - protected override bool IsEnabledCore() => Owner.IsEnabled; + protected override bool IsEnabledCore() => Owner.IsEffectivelyEnabled; protected override bool IsKeyboardFocusableCore() => Owner.Focusable; protected override void SetFocusCore() => Owner.Focus();