Skip to content

Datepicker time changes do not fire onChange event unless user clicks "ok" button. #2257

@mrfixij

Description

@mrfixij

Describe the bug
When using the datepicker time component - the valueChanged callback is only called when the OK button is pressed and not when clicking outside of the popup to close it. This also leaves the state in a confusing place because value is not updated in the below example.

To Reproduce
Steps to reproduce the behavior:

  1. Using the basic Define Hour datepicker as a template: update the code to the following.
    <RadzenLabel Text="Select Date" Component="DatePickerHourFormat" />
    <RadzenDatePicker TValue=DateTime? Value=@value ValueChanged=@OnValueChanged ShowTime="true" HourFormat="12" DateFormat="MM/dd/yyyy h:mm tt" Name="DatePickerHourFormat" />
    
</RadzenStack>
<EventConsole @ref=@console />

@code {
    DateTime? value = DateTime.Now;
    EventConsole console;
    private void OnValueChanged(DateTime? newValue)
    {
        console.Log(newValue); 
        value = newValue.Value;
    }
}
  1. Open the datepicker, change the date. Observe that the console has logged the dateTime updating.
  2. Open the datepicker. Change the time using the up/down arrows on the UI. Close the datepicker by clicking outside of the modal. Observe that the console has not logged the new time.
  3. Repeat step 3, but close the datepicker by clicking the OK button instead. Observe that the console has logged the new time.

Expected behavior
When closing the modal without the OK button, the ValueChanged event should fire

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions