Declined
Last Updated: 23 Jul 2024 09:19 by ADMIN
Domingos Portela
Created on: 16 Jul 2024 11:29
Category: DateTimePicker
Type: Bug Report
0
OnChange triggers two times

In the TelerikDatePicker, when I select the date and click outside, the event triggers one time only, but when I do the same inside the TelerikDateTimePicker it triggers two times (the first when I set the time and the second when I click outside).

In the end of the ticket I will provide a simple demo code used in Telerik REPL for Blazor comparing the behaviour between the two elements.

Additionally I would like to report the fact that in the TelerikDateTimePicker, when there's no value and I open the calendar and click "Set" without doing anything else, the DateTime is set to "01/01/0001 00:00" instead of null.

<TelerikDatePicker @bind-Value="@DatePickerValue" OnChange="@DatePickerHandler" Format="dd/MM/yyyy" />
DatePicker triggered @DatePickerTriggerCount time(s)
<br />
<br />
<TelerikDateTimePicker @bind-Value="@DateTimePickerValue" OnChange="@DateTimePickerHandler" Format="dd/MM/yyyy HH:mm" />
DateTimePicker triggered @DateTimePickerTriggerCount time(s)
@code {
    private int DatePickerTriggerCount { get; set; }
    private int DateTimePickerTriggerCount { get; set; }
    private DateTime? DatePickerValue { get; set; }
    private DateTime? DateTimePickerValue { get; set; }
    private void DatePickerHandler(object userInput)
    {
        DatePickerTriggerCount += 1;
    }
    private void DateTimePickerHandler(object userInput)
    {
        DateTimePickerTriggerCount += 1;
    }
}
1 comment
ADMIN
Svetoslav Dimitrov
Posted on: 23 Jul 2024 09:19

Hello Domingos,

This is the expected behavior in the context of the DateTimePicker. The OnChange event fires as a confirmation that the user finished the input. In the case of the DateTimePicker, the OnChange will fire when the user clicks the Set button and when the component loses focus. 

The topic of clicking the Set button if no time or value is set, we have an open feature request for the Calendar @bind-Value parameter should accept a null value, this is the reason for the behavior. I have added your Vote for it and you can click the Follow button to receive email notifications on status updates.

That said, I am marking this bug report as declined as the behavior that is reported in it is by design.

Regards,
Svetoslav Dimitrov
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024