Skip to content

Commit 024cb4e

Browse files
SuthiYuvarajMartyIX
authored andcommitted
Fix Stepper control fails to reach maximum value when increment exceeds remaining threshold (#29763)
* Fix for 29740 * Update Issue29740.cs * Update src/Controls/tests/TestCases.HostApp/Issues/Issue29740.cs indentation changes Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com> * Update src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29740.cs Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com> --------- Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
1 parent 7b47919 commit 024cb4e

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 29740, "[Windows] Stepper control fails to reach maximum value when increment exceeds remaining threshold",
4+
PlatformAffected.UWP)]
5+
public class Issue29740 : ContentPage
6+
{
7+
Label stepperValueLabel;
8+
Stepper myStepper;
9+
10+
public Issue29740()
11+
{
12+
// Initialize the label
13+
stepperValueLabel = new Label
14+
{
15+
AutomationId = "29740StepperValueLabel",
16+
Text = "Stepper Value: 0",
17+
FontSize = 18,
18+
HorizontalOptions = LayoutOptions.Center
19+
};
20+
21+
// Initialize the stepper
22+
myStepper = new Stepper
23+
{
24+
AutomationId = "29740Stepper",
25+
Minimum = 0,
26+
Maximum = 10,
27+
Increment = 3,
28+
HorizontalOptions = LayoutOptions.Center
29+
};
30+
myStepper.ValueChanged += OnStepperValueChanged;
31+
32+
// Create the layout
33+
var verticalStack = new VerticalStackLayout
34+
{
35+
Padding = new Thickness(30, 0),
36+
Spacing = 25,
37+
Children =
38+
{
39+
stepperValueLabel,
40+
myStepper
41+
}
42+
};
43+
44+
// Embed in a ScrollView
45+
Content = new ScrollView
46+
{
47+
Content = verticalStack
48+
};
49+
50+
// Optionally update initial value display
51+
UpdateLabel(myStepper.Value);
52+
}
53+
54+
private void OnStepperValueChanged(object sender, ValueChangedEventArgs e)
55+
{
56+
UpdateLabel(e.NewValue);
57+
}
58+
59+
private void UpdateLabel(double value)
60+
{
61+
stepperValueLabel.Text = $"Stepper Value: {value}";
62+
}
63+
}
64+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue29740 : _IssuesUITest
8+
{
9+
public Issue29740(TestDevice device) : base(device)
10+
{
11+
}
12+
13+
public override string Issue => "[Windows] Stepper control fails to reach maximum value when increment exceeds remaining threshold";
14+
15+
[Test]
16+
[Category(UITestCategories.Stepper)]
17+
public void GestureRecognizersOnLabelSpanShouldWork()
18+
{
19+
var initialvalue = App.WaitForElement("29740StepperValueLabel").GetText();
20+
Assert.That(initialvalue, Is.EqualTo("Stepper Value: 0"));
21+
for (int i = 0; i < 4; i++)
22+
{
23+
App.IncreaseStepper("29740Stepper");
24+
}
25+
var finalvalue = App.WaitForElement("29740StepperValueLabel").GetText();
26+
Assert.That(finalvalue, Is.EqualTo("Stepper Value: 10"));
27+
}
28+
}

src/Core/src/Platform/Windows/MauiStepper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ void UpdateEnabled(double value)
258258
void UpdateValue(double delta)
259259
{
260260
double newValue = Value + delta;
261-
if (newValue > Maximum || newValue < Minimum)
262-
return;
263-
264261
Value = newValue;
265262
}
266263

0 commit comments

Comments
 (0)