Skip to content
Merged
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32266.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32266, "TimePicker on Windows Defaults to Midnight When Time Value Is Null", PlatformAffected.UWP)]
public class Issue32266 : ContentPage
{
TimePicker timePicker;
Button clearTimeButton;
Button setTimeButton;

public Issue32266()
{
timePicker = new TimePicker
{
AutomationId = "Issue32266TimePicker",
Time = null,
Format = "hh:mm"
};

setTimeButton = new Button
{
AutomationId = "SetTimeButton",
Text = "Set Time to 6:00 AM"
};
setTimeButton.Clicked += SetTime_Clicked;

clearTimeButton = new Button
{
AutomationId = "ClearTimeButton",
Text = "Clear Time (Set to Null)"
};
clearTimeButton.Clicked += ClearTime_Clicked;

VerticalStackLayout stackLayout = new VerticalStackLayout
{
Padding = 25,
Spacing = 10,
Children = { timePicker, setTimeButton, clearTimeButton }
};

Content = stackLayout;
}

void SetTime_Clicked(object sender, EventArgs e)
{
timePicker.Time = new TimeSpan(6, 0, 0);
}

void ClearTime_Clicked(object sender, EventArgs e)
{
timePicker.Time = null;
}
}
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
@@ -0,0 +1,35 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

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

public override string Issue => "TimePicker on Windows Defaults to Midnight When Time Value Is Null";

[Test, Order(1)]
[Category(UITestCategories.TimePicker)]
public void VerifyTimePickerIsNullOnInitialLoad()
{
App.WaitForElement("Issue32266TimePicker");
VerifyScreenshot();
}

[Test, Order(2)]
[Category(UITestCategories.TimePicker)]
public void VerifyClearedTimeDoesNotShowMidnight()
{
App.WaitForElement("SetTimeButton");
App.Tap("SetTimeButton");

App.WaitForElement("ClearTimeButton");
App.Tap("ClearTimeButton");

VerifyScreenshot();
}
}
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.
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.
6 changes: 3 additions & 3 deletions src/Core/src/Handlers/TimePicker/TimePickerHandler.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public partial class TimePickerHandler : ViewHandler<ITimePicker, TimePicker>

protected override void ConnectHandler(TimePicker platformView)
{
platformView.TimeChanged += OnControlTimeChanged;
platformView.SelectedTimeChanged += OnSelectedTimeChanged;
}

protected override void DisconnectHandler(TimePicker platformView)
{
platformView.TimeChanged -= OnControlTimeChanged;
platformView.SelectedTimeChanged -= OnSelectedTimeChanged;
}

public static void MapFormat(ITimePickerHandler handler, ITimePicker timePicker)
Expand Down Expand Up @@ -54,7 +54,7 @@ internal static void MapIsOpen(ITimePickerHandler handler, ITimePicker timePicke
handler.PlatformView?.UpdateIsOpen(timePicker);
}

void OnControlTimeChanged(object? sender, TimePickerValueChangedEventArgs e)
void OnSelectedTimeChanged(TimePicker sender, TimePickerSelectedValueChangedEventArgs e)
{
if (VirtualView is not null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Platform/Windows/TimePickerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class TimePickerExtensions
{
public static void UpdateTime(this TimePicker nativeTimePicker, ITimePicker timePicker)
{
nativeTimePicker.Time = timePicker.Time ?? TimeSpan.Zero;
nativeTimePicker.SelectedTime = timePicker.Time;

if (timePicker.Format?.Contains('H', StringComparison.Ordinal) == true)
{
Expand Down
Loading