Declined
Last Updated: 26 Apr 2024 16:57 by ADMIN
Brightstar
Created on: 17 Apr 2024 19:38
Category: Kendo UI for jQuery
Type: Bug Report
1
Kendo DatePicker type attribute not correct for DateTime values when soft-refreshing (F5) page in FireFox

Context: There is an item that illustrates the issue here: https://www.telerik.com/forums/kendo-datepicker-value-not-populated-after-refresh-firefox-only

In Firefox, when using the asp-for tag helper to bind a c# DateTime field to an input element, then calling kendoDatePicker() on that element, the control fails to populate on a soft-refresh (F5). Upon reloading using F5 in Firefox, the input's type is set to datetime-localand the input 's control variation is changed to the default date picker.  Then, the Kendo UI DatePicker is initialized with a blank input which normally has a type of text

Example project and video of issue are attached.

This is the pertinent code (also happens in latest version of Kendo as well):

    public class IndexViewModel
    {
        public DateTime DateAsDateTime { get; set; }
    }
        public IActionResult Index()
        {
            return View(new IndexViewModel { DateAsDateTime = DateTime.Today });
        }
@model IndexViewModel

<input id="dtDate" asp-for="@Model.DateAsDateTime">

<script type="text/javascript">
    $(document).ready(function () {
        $("#dtDate").kendoDatePicker();
    });
</script>

1 comment
ADMIN
Patrick | Technical Support Engineer, Senior
Posted on: 26 Apr 2024 16:57

Hi,

It has been confirmed this behavior is due to how Firefox handles their asp-for attributes. 

When the page is initially loaded, the asp-for attribute applies the value with the format dd-MM-yyyyTHH:mm:ss.ttt(or something similar).  The Kendo UI DatePicker becomes initialized, and the value is updated to match the format from the datepicker configuration(the default format is MM/dd/yyyy).

When the page is refreshed using F5 with Firefox, it caches and persists the asp-for attributes.  The format for the input will be set to MM/dd/yyyy on the refresh. So, the asp model fails to parse that formatting, and the value is not set.

Regarding the Kendo UI DatePicker, it only applies a format for the date. If, for example, the following format is set to the widget: dd-MM-yyyyTHH:mm:ss.ttt , then everything will function as expected and the value will not be empty.

Therefore, as this is a caching issue specific to the interaction with Firefox and ASP.NET, this issue is consider not a bug for Kendo UI for jQuery.  In this use-case, please consider using asp-for at your discretion for the input.

Regards,
Patrick | Technical Support Engineer, Senior
Progress Telerik

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