[Windows] Maui Stepper: Clamp minimum and maximum value#33275
[Windows] Maui Stepper: Clamp minimum and maximum value#33275PureWeen merged 2 commits intodotnet:inflight/currentfrom
Conversation
|
@OomJan can you please add tests? |
|
@dotnet-policy-service agree |
Test added. |
Review Feedback: PR #33275 - [Windows] Maui Stepper: Clamp minimum and maximum valueRecommendation✅ Approve with Minor Suggestions Required changes: Recommended changes:
📋 Full PR Review DetailsSummaryThis PR fixes a Windows-specific bug where the MauiStepper control's internal value could drift beyond min/max boundaries, causing confusing behavior where users needed multiple button clicks before seeing value changes. The fix adds proper value clamping in the Key Points:
Code ReviewProblem AnalysisRoot Cause: The Windows platform's
The Bug Scenario:
Why Other Platforms Don't Have This:
The Fixvoid UpdateValue(double delta)
{
double newValue = Value + delta;
// Minimum check
newValue = Math.Max(newValue, Minimum);
// Maximum check
newValue = Math.Min(newValue, Maximum);
Value = newValue;
}Why This Works:
Alternative Approaches Considered:
Code Quality✅ Strengths:
Test CoverageOriginal Tests (Issue33274.cs)✅ Well-designed test scenarios: Scenario 1 - Maximum boundary: // Start at Maximum (1), increment (blocked), decrement (should work immediately)
Stepper: Value=1, Min=0, Max=1, Increment=1
App.IncreaseStepper("Maximumstepper"); // Internal would go 1→2 without fix
App.DecreaseStepper("Maximumstepper"); // Should show 0 immediately
Assert: Label.Text == "0"Scenario 2 - Minimum boundary: // Start at Minimum (0), decrement (blocked), increment (should work immediately)
Stepper: Value=0, Min=0, Max=1, Increment=1
App.DecreaseStepper("Minimumstepper"); // Internal would go 0→-1 without fix
App.IncreaseStepper("Minimumstepper"); // Should show 1 immediately
Assert: Label.Text == "1"✅ Test quality:
Typos fixed:
Edge Case Tests AddedI've created two additional test scenarios to validate edge cases: Test 1: Issue33274_RapidClick
Test 2: Issue33274_LargeIncrement
Test Coverage Summary
Testing ResultsPlatform: Windows (local testing not available via BuildAndRunHostApp.ps1) Note: The BuildAndRunHostApp.ps1 script currently only supports Manual Validation Required:
Alternative Validation Approach:
Edge Cases Analyzed1. ✅ Rapid Clicking (Tested)Scenario: User rapidly clicks increment 10 times at maximum 2. ✅ Large Increment (Tested)Scenario: Increment=5, value=8, max=10, user clicks increment 3.
|
|
Our PR-reviewer agent suggested adding two additional edge cases for testing. They’re not must-haves in my view, but you’re welcome to add them if you think they make sense. [Test]
[Category(UITestCategories.Stepper)]
public void RapidClickAtMaximumShouldNotDrift()
{
App.WaitForElement("RapidLabel");
// Verify starting at maximum
Assert.That(App.FindElement("RapidLabel").GetText(), Is.EqualTo("5"));
// Rapid click increment 10 times at maximum
for (int i = 0; i < 10; i++)
{
App.IncreaseStepper("RapidStepper");
}
// Value should still be at maximum
Assert.That(App.FindElement("RapidLabel").GetText(), Is.EqualTo("5"));
// Single decrement should immediately work
App.DecreaseStepper("RapidStepper");
Assert.That(App.FindElement("RapidLabel").GetText(), Is.EqualTo("4"));
// Continue decrementing to verify no drift
App.DecreaseStepper("RapidStepper");
Assert.That(App.FindElement("RapidLabel").GetText(), Is.EqualTo("3"));
} [Test]
[Category(UITestCategories.Stepper)]
public void LargeIncrementNearMaximumShouldClamp()
{
App.WaitForElement("LargeLabel");
// Verify starting value
Assert.That(App.FindElement("LargeLabel").GetText(), Is.EqualTo("8"));
// Increment by 5 (would go to 13, but should clamp to 10)
App.IncreaseStepper("LargeStepper");
Assert.That(App.FindElement("LargeLabel").GetText(), Is.EqualTo("10"));
// Another increment should keep it at 10
App.IncreaseStepper("LargeStepper");
Assert.That(App.FindElement("LargeLabel").GetText(), Is.EqualTo("10"));
// Decrement should work immediately (no drift from 13 -> 8)
App.DecreaseStepper("LargeStepper");
Assert.That(App.FindElement("LargeLabel").GetText(), Is.EqualTo("5"));
} |
|
Amazing! Thank you for your contribution!! Happy Holidays |
|
Congrats @OomJan on your first contribution! |
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes #33274
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 27 commits with various improvements, bug fixes, and enhancements. ## CollectionView - [iOS][CV2] Fix page can be dragged down, and it would cause an extra space between Header and EmptyView text by @devanathan-vaithiyanathan in #31840 <details> <summary>🔧 Fixes</summary> - [I8_Header_and_Footer_Null - The page can be dragged down, and it would cause an extra space between Header and EmptyView text.](#31465) </details> - [iOS] Fixed the Items not displayed properly in CarouselView2 by @Ahamed-Ali in #31336 <details> <summary>🔧 Fixes</summary> - [[iOS] Items are not updated properly in CarouselView2.](#31148) </details> ## Docs - Improve Controls Core API docs by @jfversluis in #33240 ## Editor - [iOS] Fixed an issue where an Editor with a small height inside a ScrollView would cause the entire page to scroll by @Tamilarasan-Paranthaman in #27948 <details> <summary>🔧 Fixes</summary> - [[iOS][Editor] An Editor that has not enough height and resides inside a ScrollView/CollectionView will scroll the entire page](#27750) </details> ## Image - [Android] Image control crashes on Android when image width exceeds height by @KarthikRajaKalaimani in #33045 <details> <summary>🔧 Fixes</summary> - [Image control crashes on Android when image width exceeds height](#32869) </details> ## Mediapicker - [Android 🤖] Add a log telling why the request is cancelled by @pictos in #33295 <details> <summary>🔧 Fixes</summary> - [MediaPicker.PickPhotosAsync throwing TaskCancelledException in net10-android](#33283) </details> ## Navigation - [Android] Fix for App Hang When PopModalAsync Is Called Immediately After PushModalAsync with Task.Yield() by @BagavathiPerumal in #32479 <details> <summary>🔧 Fixes</summary> - [App hangs if PopModalAsync is called after PushModalAsync with single await Task.Yield()](#32310) </details> - [iOS 26] Navigation hangs after rapidly open and closing new page using Navigation.PushAsync - fix by @kubaflo in #32456 <details> <summary>🔧 Fixes</summary> - [[iOS 26] Navigation hangs after rapidly open and closing new page using Navigation.PushAsync](#32425) </details> ## Pages - [iOS] Fix ContentPage BackgroundImageSource not working by @Shalini-Ashokan in #33297 <details> <summary>🔧 Fixes</summary> - [.Net MAUI- Page.BackgroundImageSource not working for iOS](#21594) </details> ## RadioButton - [Issue-Resolver] Fix #33264 - RadioButtonGroup not working with Collection View by @kubaflo in #33343 <details> <summary>🔧 Fixes</summary> - [RadioButtonGroup not working with CollectionView](#33264) </details> ## SafeArea - [Android] Fixed Label Overlapped by Android Status Bar When Using SafeAreaEdges="Container" in .NET MAUI by @NirmalKumarYuvaraj in #33285 <details> <summary>🔧 Fixes</summary> - [SafeAreaEdges works correctly only on the first tab in Shell. Other tabs have content colliding with the display cutout in the landscape mode.](#33034) - [Label Overlapped by Android Status Bar When Using SafeAreaEdges="Container" in .NET MAUI](#32941) - [[MAUI 10] Layout breaks on first navigation (Shell // route) until soft keyboard appears/disappears (Android + iOS)](#33038) </details> ## ScrollView - [Windows, Android] Fix ScrollView Content Not Removed When Set to Null by @devanathan-vaithiyanathan in #33069 <details> <summary>🔧 Fixes</summary> - [[Windows, Android] ScrollView Content Not Removed When Set to Null](#33067) </details> ## Searchbar - Fix Android crash when changing shared Drawable tint on Searchbar by @tritter in #33071 <details> <summary>🔧 Fixes</summary> - [[Android] Crash on changing Tint of Searchbar](#33070) </details> ## Shell - [iOS] - Fix Custom FlyoutIcon from Being Overridden to Default Color in Shell by @prakashKannanSf3972 in #27580 <details> <summary>🔧 Fixes</summary> - [Change the flyout icon color](#6738) </details> - [iOS] Fix Shell NavBarIsVisible updates when switching ShellContent by @Vignesh-SF3580 in #33195 <details> <summary>🔧 Fixes</summary> - [[iOS] Shell NavBarIsVisible is not updated when changing ShellContent](#33191) </details> ## Slider - [C] Fix Slider and Stepper property order independence by @StephaneDelcroix in #32939 <details> <summary>🔧 Fixes</summary> - [Slider Binding Initialization Order Causes Incorrect Value Assignment in XAML](#32903) - [Slider is very broken, Value is a mess when setting Minimum](#14472) - [Slider is buggy depending on order of properties](#18910) - [Stepper Value is incorrectly clamped to default min/max when using bindableproperties in MVVM pattern](#12243) - [[Issue-Resolver] Fix #32903 - Sliderbinding initialization order issue](#32907) </details> ## Stepper - [Windows] Maui Stepper: Clamp minimum and maximum value by @OomJan in #33275 <details> <summary>🔧 Fixes</summary> - [[Windows] Maui Stepper is not clamped to minimum or maximum internally](#33274) </details> - [iOS] Fixed the UIStepper Value from being clamped based on old higher MinimumValue - Candidate PR test failure fix- 33363 by @Ahamed-Ali in #33392 ## TabbedPage - [windows] Fixed Rapid change of selected tab results in crash. by @praveenkumarkarunanithi in #33113 <details> <summary>🔧 Fixes</summary> - [Rapid change of selected tab results in crash on Windows.](#32824) </details> ## Titlebar - [Mac] Fix TitleBar Content Overlapping with Traffic Light Buttons on Latest macOS Version by @devanathan-vaithiyanathan in #33157 <details> <summary>🔧 Fixes</summary> - [TitleBar Content Overlapping with Traffic Light Buttons on Latest macOS Version](#33136) </details> ## Xaml - Fix for Control does not update from binding anymore after MultiBinding.ConvertBack is called by @BagavathiPerumal in #33128 <details> <summary>🔧 Fixes</summary> - [Control does not update from binding anymore after MultiBinding.ConvertBack is called](#24969) - [The issue with the MultiBinding converter with two way binding mode does not work properly when changing the values.](#20382) </details> <details> <summary>🔧 Infrastructure (1)</summary> - Avoid KVO on CALayer by introducing an Apple PlatformInterop by @albyrock87 in #30861 </details> <details> <summary>🧪 Testing (2)</summary> - [Testing] Enable UITest Issue18193 on MacCatalyst by @NafeelaNazhir in #31653 <details> <summary>🔧 Fixes</summary> - [Test Issue18193 was disabled on Mac Catalyst](#27206) </details> - Set the CV2 handlers as the default by @Ahamed-Ali in #33177 </details> <details> <summary>📦 Other (3)</summary> - Update WindowsAppSDK to 1.8 by @mattleibow in #32174 <details> <summary>🔧 Fixes</summary> - [Update to WindowsAppSDK](#30858) </details> - Fix command dependency reentrancy by @simonrozsival in #33129 - Fix SafeArea AdjustPan handling and add AdjustNothing mode tests by @PureWeen via @Copilot in #33354 </details> **Full Changelog**: main...inflight/candidate
### Description of Change Clamping value to minimum and maximum in the MauiStepper for Windows implementation. ### Issues Fixed Fixes dotnet#33274
Description of Change
Clamping value to minimum and maximum in the MauiStepper for Windows implementation.
Issues Fixed
Fixes #33274