From 0f4bb0ae45ce0536b03dfec1538317da71aff32c Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Mon, 1 Sep 2025 16:58:57 +0530 Subject: [PATCH 1/6] Fix for IndicatorView IsEnabled --- .../TestCases.HostApp/Issues/Issue31063.cs | 72 +++++++++++++++++++ .../Tests/Issues/Issue31063.cs | 23 ++++++ .../src/Platform/Android/MauiPageControl.cs | 12 +++- 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs new file mode 100644 index 000000000000..eb4c30c7c824 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs @@ -0,0 +1,72 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 31063, "IndicatorView remains interactive even when IsEnabled is False", PlatformAffected.Android)] +public partial class Issue31063 : ContentPage +{ + private CarouselView _carouselView; + private IndicatorView _indicatorView; + + public Issue31063() + { + // Create StackLayout + var stackLayout = new StackLayout + { + Padding = 20, + Spacing = 20 + }; + + // CarouselView + _carouselView = new CarouselView + { + HeightRequest = 200, + ItemsSource = new string[] + { + "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" + }, + ItemTemplate = new DataTemplate(() => + { + var label = new Label + { + FontSize = 30, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + Padding = 20 + }; + label.SetBinding(Label.TextProperty, "."); + return label; + }) + }; + + // IndicatorView + _indicatorView = new IndicatorView + { + AutomationId = "TestIndicatorView", + IndicatorColor = Colors.LightGray, + SelectedIndicatorColor = Colors.Blue, + IndicatorSize = 25, + IsEnabled = false, + HorizontalOptions = LayoutOptions.Center + }; + + // Bind Indicator to Carousel + _indicatorView.SetBinding(IndicatorView.ItemsSourceProperty, new Binding + { + Source = _carouselView, + Path = "ItemsSource" + }); + + _indicatorView.SetBinding(IndicatorView.PositionProperty, new Binding + { + Source = _carouselView, + Path = "Position", + Mode = BindingMode.TwoWay + }); + + // Add children + stackLayout.Children.Add(_carouselView); + stackLayout.Children.Add(_indicatorView); + + // Set Content + Content = stackLayout; + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs new file mode 100644 index 000000000000..b4d9bc756dac --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue31063 : _IssuesUITest +{ + public override string Issue => "IndicatorView remains interactive even when IsEnabled is False"; + + public Issue31063(TestDevice device) : base(device) + { + } + + [Test] + [Category(UITestCategories.IndicatorView)] + public void IndicatorViewShouldRespectIsEnabledProperty() + { + App.WaitForElement("TestIndicatorView"); + App.Tap("TestIndicatorView"); + App.WaitForElement("Item 1"); + } +} diff --git a/src/Core/src/Platform/Android/MauiPageControl.cs b/src/Core/src/Platform/Android/MauiPageControl.cs index 087f239a0c90..3989e781b258 100644 --- a/src/Core/src/Platform/Android/MauiPageControl.cs +++ b/src/Core/src/Platform/Android/MauiPageControl.cs @@ -96,7 +96,7 @@ public void UpdateIndicatorCount() var position = (int)view.Tag; _indicatorView.Position = position; } - })); + }, _indicatorView)); AddView(imageView); } @@ -189,14 +189,21 @@ void RemoveViews(int startAt) class TEditClickListener : Java.Lang.Object, IOnClickListener { Action? _command; + IIndicatorView? _indicatorView; - public TEditClickListener(Action command) + public TEditClickListener(Action command, IIndicatorView? indicatorView) { _command = command; + _indicatorView = indicatorView; } public void OnClick(AView? v) { + if (_indicatorView?.IsEnabled == false) + { + return; + } + _command?.Invoke(v); } protected override void Dispose(bool disposing) @@ -204,6 +211,7 @@ protected override void Dispose(bool disposing) if (disposing) { _command = null; + _indicatorView = null; } base.Dispose(disposing); } From dccf8f0a178b60130c71df37949a80f47a4dcca4 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Mon, 1 Sep 2025 17:14:55 +0530 Subject: [PATCH 2/6] Removed Private Keyword --- src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs index eb4c30c7c824..c45057da01f5 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue31063.cs @@ -3,8 +3,8 @@ [Issue(IssueTracker.Github, 31063, "IndicatorView remains interactive even when IsEnabled is False", PlatformAffected.Android)] public partial class Issue31063 : ContentPage { - private CarouselView _carouselView; - private IndicatorView _indicatorView; + CarouselView _carouselView; + IndicatorView _indicatorView; public Issue31063() { From 636757536a25c1fc0885b19aa839701e8b0c1790 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Tue, 2 Sep 2025 11:26:32 +0530 Subject: [PATCH 3/6] Test restricted on windows --- .vscode/launch.json | 14 ++++++++++++++ .../Tests/Issues/Issue31063.cs | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..a81bd58ee982 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET MAUI", + "type": "maui", + "request": "launch", + "preLaunchTask": "maui: Build" + } + ] +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs index b4d9bc756dac..7ae7f9e86e2c 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_WINDOWS // IndicatorView UI automation not working on Windows +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -21,3 +22,4 @@ public void IndicatorViewShouldRespectIsEnabledProperty() App.WaitForElement("Item 1"); } } +#endif \ No newline at end of file From b25ad543fd82b8286afbf2099d447f73ad6b565a Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Tue, 2 Sep 2025 11:28:14 +0530 Subject: [PATCH 4/6] Remove unwanted file --- .vscode/launch.json | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a81bd58ee982..000000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET MAUI", - "type": "maui", - "request": "launch", - "preLaunchTask": "maui: Build" - } - ] -} \ No newline at end of file From 620ccf2838ab8dba7af6ca41c56e99bba3f41d72 Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Tue, 2 Sep 2025 17:36:34 +0530 Subject: [PATCH 5/6] Modified the fix --- src/Core/src/Platform/Android/MauiPageControl.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Core/src/Platform/Android/MauiPageControl.cs b/src/Core/src/Platform/Android/MauiPageControl.cs index 3989e781b258..17f7bc719140 100644 --- a/src/Core/src/Platform/Android/MauiPageControl.cs +++ b/src/Core/src/Platform/Android/MauiPageControl.cs @@ -91,12 +91,12 @@ public void UpdateIndicatorCount() imageView.SetOnClickListener(new TEditClickListener(view => { - if (view?.Tag != null) + if (view?.Tag != null && _indicatorView.IsEnabled) { var position = (int)view.Tag; _indicatorView.Position = position; } - }, _indicatorView)); + })); AddView(imageView); } @@ -189,21 +189,14 @@ void RemoveViews(int startAt) class TEditClickListener : Java.Lang.Object, IOnClickListener { Action? _command; - IIndicatorView? _indicatorView; - public TEditClickListener(Action command, IIndicatorView? indicatorView) + public TEditClickListener(Action command) { _command = command; - _indicatorView = indicatorView; } public void OnClick(AView? v) { - if (_indicatorView?.IsEnabled == false) - { - return; - } - _command?.Invoke(v); } protected override void Dispose(bool disposing) @@ -211,7 +204,6 @@ protected override void Dispose(bool disposing) if (disposing) { _command = null; - _indicatorView = null; } base.Dispose(disposing); } From 2a355b8060222bc269e12087e7bb351d9ad45a1b Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Tue, 2 Sep 2025 17:50:43 +0530 Subject: [PATCH 6/6] Modify fix --- src/Core/src/Platform/Android/MauiPageControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/Android/MauiPageControl.cs b/src/Core/src/Platform/Android/MauiPageControl.cs index 17f7bc719140..d14295352959 100644 --- a/src/Core/src/Platform/Android/MauiPageControl.cs +++ b/src/Core/src/Platform/Android/MauiPageControl.cs @@ -91,7 +91,7 @@ public void UpdateIndicatorCount() imageView.SetOnClickListener(new TEditClickListener(view => { - if (view?.Tag != null && _indicatorView.IsEnabled) + if (_indicatorView.IsEnabled && view?.Tag != null) { var position = (int)view.Tag; _indicatorView.Position = position;