-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implemented ios:Slider.UpdateOnTap #20124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jfversluis
merged 5 commits into
dotnet:inflight/current
from
kubaflo:ios-slider-UpdateOnTap
Nov 26, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System; | ||
| using Microsoft.Maui.Controls.Compatibility; | ||
|
|
||
| namespace Microsoft.Maui.Controls | ||
| { | ||
| public partial class Slider | ||
| { | ||
| internal static new void RemapForControls() | ||
| { | ||
| // Adjust the mappings to preserve Controls.Slider legacy behaviors | ||
| #if IOS | ||
| SliderHandler.Mapper.ReplaceMapping<Slider, ISliderHandler>(PlatformConfiguration.iOSSpecific.Slider.UpdateOnTapProperty.PropertyName, MapUpdateOnTap); | ||
| #endif | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| using Microsoft.Maui.Controls.Platform; | ||
| using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; | ||
|
|
||
| namespace Microsoft.Maui.Controls | ||
| { | ||
| public partial class Slider | ||
| { | ||
| internal static void MapUpdateOnTap(SliderHandler handler, Slider slider) => | ||
| MapUpdateOnTap((ISliderHandler)handler, slider); | ||
|
|
||
| internal static void MapUpdateOnTap(ISliderHandler handler, Slider slider) | ||
| { | ||
| if (handler is SliderHandler sliderHandler) | ||
| { | ||
| sliderHandler.MapUpdateOnTap(slider.OnThisPlatform().GetUpdateOnTap()); | ||
| } | ||
| } | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/DeviceTests/Elements/Slider/SliderTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System; | ||
| using System.ComponentModel; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Handlers.Compatibility; | ||
| using Microsoft.Maui.Graphics; | ||
| using Microsoft.Maui.Handlers; | ||
| using Microsoft.Maui.Hosting; | ||
| using Microsoft.Maui.Platform; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Maui.DeviceTests | ||
| { | ||
| [Category(TestCategory.Slider)] | ||
| public partial class SliderTests : ControlsHandlerTestBase | ||
| { | ||
| void SetupBuilder() | ||
| { | ||
| EnsureHandlerCreated(builder => | ||
| { | ||
| builder.ConfigureMauiHandlers(handlers => | ||
| { | ||
| handlers.AddHandler<Slider, SliderHandler>(); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
src/Controls/tests/DeviceTests/Elements/Slider/SliderTests.iOS.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Graphics; | ||
| using Microsoft.Maui.Handlers; | ||
| using Xunit; | ||
| using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; | ||
| using Slider = Microsoft.Maui.Controls.Slider; | ||
| using Microsoft.Maui.Controls.PlatformConfiguration; | ||
|
|
||
| namespace Microsoft.Maui.DeviceTests | ||
| { | ||
| public partial class SliderTests | ||
| { | ||
| [Fact("Slider Does Not Leak")] | ||
| public async Task DoesNotLeak() | ||
| { | ||
| SetupBuilder(); | ||
| WeakReference platformViewReference = null; | ||
| WeakReference handlerReference = null; | ||
|
|
||
| await InvokeOnMainThreadAsync(() => | ||
| { | ||
| var layout = new VerticalStackLayout(); | ||
| var slider = new Slider(); | ||
| slider.On<iOS>().SetUpdateOnTap(true); | ||
| layout.Add(slider); | ||
|
|
||
| var handler = CreateHandler<LayoutHandler>(layout); | ||
| handlerReference = new WeakReference(slider.Handler); | ||
| platformViewReference = new WeakReference(slider.Handler.PlatformView); | ||
| }); | ||
|
|
||
| await AssertionExtensions.WaitForGC(handlerReference, platformViewReference); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Controls/tests/TestCases.HostApp/Issues/Issue20098.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue20098" | ||
| xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"> | ||
| <VerticalStackLayout> | ||
| <Label AutomationId="label" Text="{Binding Value, Source={x:Reference slider}}"/> | ||
| <Slider AutomationId="slider" ios:Slider.UpdateOnTap="True" x:Name="slider" Minimum="0" Maximum="100" Value="0"/> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
15 changes: 15 additions & 0 deletions
15
src/Controls/tests/TestCases.HostApp/Issues/Issue20098.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 20098, "iOS-specific Slider.UpdateOnTab", PlatformAffected.iOS)] | ||
| public partial class Issue20098 : ContentPage | ||
| { | ||
| public Issue20098() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20098.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #if IOS | ||
| using NUnit.Framework; | ||
| using NUnit.Framework.Legacy; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue20098: _IssuesUITest | ||
| { | ||
| public Issue20098(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "iOS-specific Slider.UpdateOnTab"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Picker)] | ||
| public void UpdateOnTabShouldWork() | ||
| { | ||
| _ = App.WaitForElement("slider"); | ||
| var pickerRect = App.FindElement("slider").GetRect(); | ||
| var label = App.FindElement("label"); | ||
| App.Click(pickerRect.X + pickerRect.Width / 2, pickerRect.Y); | ||
| var text = label.GetText(); | ||
|
|
||
| ClassicAssert.AreNotEqual("0", text); | ||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen do we have "design docs" on where this should live? For other Controls-only things we just kept it in the XAML control class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, if we're not adding an interface at the core level then controls level inside the xaml class makes sense