When the user opens the DateTimePicker(Time step) or the TimePicker, which are bound to some value, and clicks directly the "Set" button, the pickers don't bind the displayed time value (pre-selected value). This behavior can be seen when the pickers have configured steps (e.g. Minute: "15", Year="10" etc.)
Steps To Reproduce
The NOW button in the TimePicker's TimeView sets the time value, according to the server's time zone. Instead, it should use the client-side (user) time zone.
===
Telerik edit:
In the meantime, you can subscribe to the TimePicker's ValueChanged event and detect when the user clicks on Now. In such cases, the event handler will receive the current server time with a small margin of error, that depends on the latency.
<TelerikTimePicker Value="@TimePickerValue"
ValueChanged="@( (DateTime? d) => TimePickerValueChanged(d) )">
</TelerikTimePicker>
@code {
private DateTime? TimePickerValue { get; set; }
private void TimePickerValueChanged(DateTime? newValue)
{
if (newValue.HasValue && newValue - DateTime.Now < new TimeSpan(0, 0, 1))
{
// Retrieve and set the correct user's local time. The dummy code below is just for testing.
TimePickerValue = DateTime.Now.AddMinutes(2);
}
else
{
TimePickerValue = newValue;
}
}
}
We are noticing that scrolling and dropping the minutes in the selection box is quite jumpy\jittery. We need to get close and then manually click on the desired minute to select it.
The behavior can be reproduced in the live demo if opened on a mobile device.
Since version 4.0.0, when you initialize a time picker to start with the value of 12:00AM it will display the format instead of the actual value (for example hh:mm:ss AM, where 12:00:00 AM should have been displayed).
When you type the time in the time picker, it changes the date to the current date, while it should change only the time portion.
---
ADMIN EDIT
A workaround is to use the original year, month and date portions of the view-model field and capture the time portion from the ValueChanged event:
@selectedTime?.ToString("F")
<TelerikTimePicker Min="@Min" Max="@Max" Format="hh:mm:ss tt"
Value="@selectedTime" ValueChanged="@( (DateTime? v) => ValueChangedHandler(v) )">
</TelerikTimePicker>
@code {
public DateTime Min = new DateTime(1900, 1, 1, 10, 0, 0);
public DateTime Max = new DateTime(1900, 1, 1, 20, 0, 0);
public DateTime? selectedTime { get; set; } = new DateTime(1900, 1, 1, 12, 0, 0);
void ValueChangedHandler(DateTime? updatedTime)
{
selectedTime = new DateTime(
selectedTime.Value.Year,
selectedTime.Value.Month,
selectedTime.Value.Day,
updatedTime.Value.Hour,
updatedTime.Value.Minute,
updatedTime.Value.Second
);
}
}
---
The TimePicker scroll wheels are janky and difficult to use on mobile. They tend to jump around while scrolling with touch input.
Is this on the roadmap for improvement? We are working on a project and need to decide whether to roll our own TimePicker in the meantime.
(Note: this is an issue on both client/server side, but I am forced to choose one.)
On the DateTimePicker, when the "Set" button is clicked, the focus is given to the DateTimePicker field, so when the user clicked outside the component, the OnChange event is fired.
But the behaviour of the TimePicker is different. Indeed, after clicking on the "Set" button the TimePicker field does not get the focus, so the user can't click outside of it to fire the OnChange event.
The following code allows to manually set the focus on each ValueChanged event, but because of it the two-way binding can't be used. This code allows the TimePicker to have the same behaviour than the DateTimePicker :
<TelerikTimePicker @ref="@timepicker" Value="MyDate" OnChange="MyDateChanged"
ValueChanged="@((DateTime d) => { MyDate = d; timepicker.FocusAsync(); })"></TelerikTimePicker>
@code {
private DateTime MyDate { get; set; }
private TelerikTimePicker<DateTime> timepicker;
public void MyDateChanged(object theUserInput)
{
Console.WriteLine("Event OnChange fired");
}
}
---
ADMIN EDIT
Reproducible
1. Go to the TimePicker demo https://demos.telerik.com/blazor-ui/timepicker/overview
2. open the popup
3. set a time with the Set button
**Note**: same goes for the Cancel button
### Current
focus goes somewhere (maybe on the body)
### Expected
focus goes to the input of the time picker
---
The TimePicker OnChange event fires to confirm a complete user action. From this point of view, the Set button in the component's dropdown should fire the event as well.
https://docs.telerik.com/blazor-ui/components/timepicker/eventsWhen setting time from AM/PM vice-versa (after setting hour and minute), the time is reset.
Observed in the demo also;
https://demos.telerik.com/blazor-ui/timepicker/overview
This means that the user needs to set AM/PM first, which doesn't follow, as the AM/PM is the right-most UI element.
---
ADMIN EDIT
This is a configuration setup, and not a bug - see the discussion below on the Min and Max features.
---