Declined
Last Updated: 10 Jun 2024 14:28 by ADMIN
Michael
Created on: 03 Jun 2024 17:02
Category: DateInput
Type: Bug Report
0
DateInput does not fire OnChange when clear button is clicked

Reproduceable example: https://blazorrepl.telerik.com/wSEgunbK46sVmd1p02

In my use case, I have custom components that wrap each of the telerik date controls (date picker, time picker, etc). They each expose a SelectedDate/SelectedTime/etc. bindable property. The SelectedDate is populated when the telerik control in my component (like TelerikDatePicker) fires OnChange. I use this instead of ValueChanged to avoid too many UI updates while the user selects a value in the UI, such as when typing. The OnChange event fires when the date input loses focus, but if the date input didn't have focus when the clear button is clicked, it never loses foucs and never fires OnChange. Let me know if this isn't intended to be supported and I should just be using ValueChanged instead, but to me OnChange would imply it would fire in all cases when the value can also change through ValueChanged, just less often.

Steps to reproduce (I used a TelerikDatePicker in the code above but I could reproduce this locally with date time picker and time picker - it's related to the underlying DateInput):

  • Enter a date into the date picker, either through typing or using the calendar popup
  • Cause the date picker to lose focus by clicking away
  • Click the clear button
  • Notice that the date is cleared from the UI control, but it doesn't call OnChange, so the date on the page never updates

When I discovered this locally, clicking the clear button would not clear the date visually from the date input as well as not updating the actual date variable. In the REPL, I was not able to replicate this - the date clears visually in the UI.

1 comment
ADMIN
Nadezhda Tacheva
Posted on: 10 Jun 2024 14:28

Hello Michael,

Thank you for sending a runnable sample and a detailed explanation for the behavior you are hitting!

The behavior indeed applies to all date and time pickers, including the DateInput and I confirm it is intentional. By design, clicking the clear button should not fire OnChange. The OnChange event fires when the user presses Enter or blurs the input.

Having the above in mind, I am marking the item as "Declined" since it does not target a valid bug but rather expected behavior.

---

Apart from that, when the user clicks the clear button, the focus should remain in the input. Or, if the input was not focused, clicking the clear button should focus the input.

However, this does not happen. Thus, the DatePicker (and other pickers) cannot detect the focus loss after that to fire OnChange as you have correctly noted. This specific behavior is not expected and I logged a bug for it: Input is never focused after clicking the clear button.

Last but not least, I want to thank you for pointing our attention to this. I rewarded your account with some Telerik points as a small gesture of appreciation for your report.

Regards,
Nadezhda Tacheva
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!