Skip to content

[iOS] Fix for DatePicker FlowDirection Not Working on iOS #30193

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue30065.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace Controls.TestCases.HostApp.Issues;

[Issue(IssueTracker.Github, 30065, "DatePicker Ignores FlowDirection When Set to RightToLeft or MatchParent", PlatformAffected.iOS)]
public class Issue30065 : ContentPage
{
public Issue30065()
{
DatePicker rtlDatePicker = new DatePicker
{
Date = new DateTime(2002, 5, 14),
WidthRequest = 300,
FlowDirection = FlowDirection.RightToLeft,
};

DatePicker ltrDatePicker = new DatePicker
{
Date = new DateTime(2002, 5, 14),
WidthRequest = 300,
FlowDirection = FlowDirection.LeftToRight,
};

Button toggleButton = new Button
{
AutomationId = "ToggleFlowDirectionBtn",
Text = "Toggle FlowDirection",
};

toggleButton.Clicked += (s, e) =>
{
rtlDatePicker.FlowDirection = FlowDirection.LeftToRight;
ltrDatePicker.FlowDirection = FlowDirection.RightToLeft;
};

VerticalStackLayout verticalStackLayout = new VerticalStackLayout
{
Padding = new Thickness(20),
VerticalOptions = LayoutOptions.Center,
Children =
{
rtlDatePicker,
ltrDatePicker,
toggleButton
}
};

Content = verticalStackLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if TEST_FAILS_ON_CATALYST // Issue Link - https://github.com/dotnet/maui/issues/30163
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

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

public override string Issue => "DatePicker Ignores FlowDirection When Set to RightToLeft or MatchParent";

[Test]
[Category(UITestCategories.DatePicker)]
public void ValidateDatePickerFlowDirection()
{
App.WaitForElement("ToggleFlowDirectionBtn");
App.Tap("ToggleFlowDirectionBtn");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshot on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

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

Running a build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , I've updated the test case and added snapshots for iOS and Android. I will add the missing snap in the next CI run.

}
}
#endif
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.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static partial void MapTextColor(IDatePickerHandler handler, IDatePicker

}

public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker)
public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker)
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The MapFlowDirection signature update on MacCatalyst is a breaking API change. Ensure that documentation and clients targeting MacCatalyst are updated accordingly.

Copilot uses AI. Check for mistakes.

{

}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/DatePicker/DatePickerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public DatePickerHandler(IPropertyMapper? mapper, CommandMapper? commandMapper)
/// </summary>
/// <param name="handler">The associated handler.</param>
/// <param name="datePicker">The associated <see cref="IDatePicker"/> instance.</param>
public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker);
public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker);
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The updated MapFlowDirection signature in the handler class changes the public API contract. This is a breaking change; please ensure API consumers are notified.

Copilot uses AI. Check for mistakes.

#endif

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static partial void MapTextColor(IDatePickerHandler handler, IDatePicker
handler.PlatformView?.UpdateTextColor(datePicker);
}

public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker)
public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker)
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The method signature change for MapFlowDirection in the iOS handler is a breaking API change. Ensure that all related documentation and client codes reflect the new interface usage.

Copilot uses AI. Check for mistakes.

{
handler.PlatformView?.UpdateFlowDirection(datePicker);
handler.PlatformView?.UpdateTextAlignment(datePicker);
Expand Down
7 changes: 6 additions & 1 deletion src/Core/src/Platform/iOS/DatePickerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ public static void UpdateMaximumDate(this UIDatePicker platformDatePicker, IDate

public static void UpdateTextAlignment(this MauiDatePicker nativeDatePicker, IDatePicker datePicker)
{
// TODO: Update TextAlignment based on the EffectiveFlowDirection property.
var alignment = nativeDatePicker.EffectiveUserInterfaceLayoutDirection ==
UIUserInterfaceLayoutDirection.RightToLeft
? UITextAlignment.Right
: UITextAlignment.Left;

nativeDatePicker.TextAlignment = alignment;
}
}
}
1 change: 0 additions & 1 deletion src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,6 @@ static Microsoft.Maui.Handlers.ContentViewHandler.Mapper -> Microsoft.Maui.IProp
static Microsoft.Maui.Handlers.DatePickerHandler.CommandMapper -> Microsoft.Maui.CommandMapper<Microsoft.Maui.IPicker!, Microsoft.Maui.Handlers.IDatePickerHandler!>!
static Microsoft.Maui.Handlers.DatePickerHandler.MapCharacterSpacing(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFont(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFormat(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapMaximumDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.<Clone>$() -> Microsoft.Maui.SwipeV
virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type!
virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool
virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool
*REMOVED*static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,6 @@ static Microsoft.Maui.Handlers.ContentViewHandler.Mapper -> Microsoft.Maui.IProp
static Microsoft.Maui.Handlers.DatePickerHandler.CommandMapper -> Microsoft.Maui.CommandMapper<Microsoft.Maui.IPicker!, Microsoft.Maui.Handlers.IDatePickerHandler!>!
static Microsoft.Maui.Handlers.DatePickerHandler.MapCharacterSpacing(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFont(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapFormat(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
static Microsoft.Maui.Handlers.DatePickerHandler.MapMaximumDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.<Clone>$() -> Microsoft.Maui.SwipeV
virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type!
virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool
virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool
*REMOVED*static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The removal and update of the MapFlowDirection signature here introduces a breaking change in the public API. Please ensure that all consumers are aware of this change and update their implementations accordingly.

Copilot uses AI. Check for mistakes.

static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void