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..c45057da01f5 --- /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 +{ + CarouselView _carouselView; + 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..7ae7f9e86e2c --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31063.cs @@ -0,0 +1,25 @@ +#if TEST_FAILS_ON_WINDOWS // IndicatorView UI automation not working on Windows +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"); + } +} +#endif \ No newline at end of file diff --git a/src/Core/src/Platform/Android/MauiPageControl.cs b/src/Core/src/Platform/Android/MauiPageControl.cs index 087f239a0c90..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) + if (_indicatorView.IsEnabled && view?.Tag != null) { var position = (int)view.Tag; _indicatorView.Position = position;