diff --git a/src/Controls/src/Core/Stepper/Stepper.cs b/src/Controls/src/Core/Stepper/Stepper.cs index f68bc03f2971..4c649b298fc2 100644 --- a/src/Controls/src/Core/Stepper/Stepper.cs +++ b/src/Controls/src/Core/Stepper/Stepper.cs @@ -12,7 +12,7 @@ public partial class Stepper : View, IElementConfiguration, IStepper { /// Bindable property for . public static readonly BindableProperty MaximumProperty = BindableProperty.Create(nameof(Maximum), typeof(double), typeof(Stepper), 100.0, - validateValue: (bindable, value) => (double)value > ((Stepper)bindable).Minimum, + validateValue: (bindable, value) => (double)value >= ((Stepper)bindable).Minimum, coerceValue: (bindable, value) => { var stepper = (Stepper)bindable; @@ -22,7 +22,7 @@ public partial class Stepper : View, IElementConfiguration, IStepper /// Bindable property for . public static readonly BindableProperty MinimumProperty = BindableProperty.Create(nameof(Minimum), typeof(double), typeof(Stepper), 0.0, - validateValue: (bindable, value) => (double)value < ((Stepper)bindable).Maximum, + validateValue: (bindable, value) => (double)value <= ((Stepper)bindable).Maximum, coerceValue: (bindable, value) => { var stepper = (Stepper)bindable; diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28330.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue28330.cs new file mode 100644 index 000000000000..021038902f33 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28330.cs @@ -0,0 +1,52 @@ +namespace Maui.Controls.Sample.Issues; +[Issue(IssueTracker.Github, 28330, "Stepper allows to increment when value equals to maximum", PlatformAffected.All)] +public class Issue28330 : TestContentPage +{ + protected override void Init() + { + var layout = new StackLayout { }; + + Stepper Incrementstepper = new Stepper + { + AutomationId = "Incrementstepper", + HorizontalOptions = LayoutOptions.Center, + Increment = 1, + Minimum = 1, + Maximum = 1, + Value = 1 + }; + + Label Incrementlabel = new Label + { + AutomationId = "Incrementlabel", + HorizontalOptions = LayoutOptions.Center, + FontSize = 32 + }; + Incrementlabel.SetBinding(Label.TextProperty, new Binding("Value", source: Incrementstepper)); + + Stepper Decrementstepper = new Stepper + { + AutomationId = "Decrementstepper", + HorizontalOptions = LayoutOptions.Center, + Increment = 1, + Maximum = 1, + Minimum = 1, + Value = 1 + }; + + Label Decrementlabel = new Label + { + AutomationId = "Decrementlabel", + HorizontalOptions = LayoutOptions.Center, + FontSize = 32 + }; + Decrementlabel.SetBinding(Label.TextProperty, new Binding("Value", source: Decrementstepper)); + + layout.Children.Add(Incrementstepper); + layout.Children.Add(Incrementlabel); + layout.Children.Add(Decrementstepper); + layout.Children.Add(Decrementlabel); + + Content = layout; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28330.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28330.cs new file mode 100644 index 000000000000..52fe15e871bc --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28330.cs @@ -0,0 +1,24 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; +public class Issue28330 : _IssuesUITest +{ + public Issue28330(TestDevice device) : base(device) + { + } + + public override string Issue => "Stepper allows to increment when value equals to maximum"; + + [Test] + [Category(UITestCategories.Stepper)] + public void Issue28330StepperIncrementShouldBeDisabled() + { + App.WaitForElement("Incrementlabel"); + App.IncreaseStepper("Incrementstepper"); + Assert.That(App.FindElement("Incrementlabel").GetText(), Is.EqualTo("1")); + App.DecreaseStepper("Decrementstepper"); + Assert.That(App.FindElement("Decrementlabel").GetText(), Is.EqualTo("1")); + } +} \ No newline at end of file