Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue35214.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 35214, "Dynamically changing IndicatorView IndicatorSize to default value does not work", PlatformAffected.iOS | PlatformAffected.macOS)]
public class Issue35214 : ContentPage
{
public Issue35214()
{
var carouselItems = new List<string> { "Item 0", "Item 1", "Item 2" };

var indicatorView = new IndicatorView
{
AutomationId = "TestIndicatorView",
HorizontalOptions = LayoutOptions.Center,
IndicatorColor = Colors.Orange,
SelectedIndicatorColor = Colors.Blue,
IndicatorSize = 20,
};

var carouselView = new CarouselView
{
ItemsSource = carouselItems,
HeightRequest = 300,
HorizontalOptions = LayoutOptions.Fill,
IndicatorView = indicatorView,
ItemTemplate = new DataTemplate(() =>
{
var label = new Label
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
FontSize = 18,
};
label.SetBinding(Label.TextProperty, ".");
return label;
}),
};

var setDefaultSizeButton = new Button
{
AutomationId = "SetDefaultSizeButton",
Text = "Set IndicatorSize = 6 (Default)",
Margin = new Thickness(0, 20, 0, 0)
};

setDefaultSizeButton.Clicked += (s, e) =>
{
indicatorView.IndicatorSize = 6;
};

Content = new VerticalStackLayout
{
Padding = 20,
Spacing = 10,
Children =
{
carouselView,
indicatorView,
setDefaultSizeButton,
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue35214 : _IssuesUITest
{
public Issue35214(TestDevice device) : base(device)
{
}

public override string Issue => "Dynamically changing IndicatorView IndicatorSize to default value does not work";

[Test, Order(1)]
[Category(UITestCategories.IndicatorView)]
public void VerifyIndicatorSizeBeforeReset()
{
App.WaitForElement("TestIndicatorView");
VerifyScreenshot("IndicatorSizeBeforeReset", retryTimeout: TimeSpan.FromSeconds(2));
}

[Test, Order(2)]
[Category(UITestCategories.IndicatorView)]
public void VerifyIndicatorSizeAfterReset()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Regression Prevention / Test Coverage - VerifyIndicatorSizeAfterReset is [Order(2)] and implicitly depends on Order(1) having run first to capture the before-state baseline and leave the page in its initial state (IndicatorSize = 20). Added comment documenting this dependency and noting the after-state assertion remains valid if run in isolation, even though the before-state screenshot would be missing.

{
App.WaitForElement("SetDefaultSizeButton");
App.Tap("SetDefaultSizeButton");
Comment thread
Shalini-Ashokan marked this conversation as resolved.
VerifyScreenshot("IndicatorSizeAfterReset", retryTimeout: TimeSpan.FromSeconds(2));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/Core/src/Platform/iOS/MauiPageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MauiPageControl : UIPageControl, IUIViewLifeCycleEvents

WeakReference<IIndicatorView>? _indicatorView;
bool _updatingPosition;
double _lastAppliedIndicatorSize = -1;
double _lastAppliedIndicatorSize = DefaultIndicatorSize;
Comment thread
Shalini-Ashokan marked this conversation as resolved.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Regression Prevention - The original _lastAppliedIndicatorSize = -1 sentinel (introduced by PR #31463 to guarantee the scale transform fires on first layout pass alongside shadows) was changed to DefaultIndicatorSize. Added comment explaining the choice and explicitly verifying PR #31463 compatibility: Math.Abs(anyNonDefaultSize - 6) > 0 so first-pass scaling still fires correctly.


public MauiPageControl()
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public override void LayoutSubviews()

public void UpdateIndicatorSize()
{
if (IndicatorSize == 0 || IndicatorSize == DefaultIndicatorSize)
if (IndicatorSize == 0 || IndicatorSize == _lastAppliedIndicatorSize)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Logic and Correctness - The IndicatorSize == 0 early-return guard silently leaves a stale scale transform when IndicatorSize is set to 0 after a non-default value. Concrete scenario: user sets IndicatorSize = 20 (scale 20/6 applied, _lastAppliedIndicatorSize = 20), then sets IndicatorSize = 0 - the old guard fires, the foreach is skipped, indicators remain visually stuck at 20/6 scale. Fixed by treating IndicatorSize == 0 as DefaultIndicatorSize via targetSize = IndicatorSize == 0 ? DefaultIndicatorSize : IndicatorSize, so Math.Abs(6 - 20) = 14 >= tolerance correctly triggers an identity-scale reset. Also removed the redundant exact-equality check since the tolerance check already subsumes it.

return;

if (Math.Abs(IndicatorSize - _lastAppliedIndicatorSize) < IndicatorSizeTolerance)
Expand Down
Loading