Hello everyone,
You can cancel the DateRangePicker OnClose event in order to keep the component open in specific scenarios. Here is an example that relies on the StartValueChanged event. You can use a similar approach for EndValueChanged.
<TelerikDateRangePicker StartValue="@StartDate"
StartValueChanged="@((DateTime newStartValue) => StartValueChanged(newStartValue))"
@bind-EndValue="@EndDate"
OnClose="@OnDateRangeClose" />
@code {
private DateTime StartDate { get; set; } = DateTime.Now.AddDays(-3);
private DateTime EndDate { get; set; } = DateTime.Now;
private bool ShouldCancelClose { get; set; }
private void StartValueChanged(DateTime newStartValue)
{
if (newStartValue < StartDate)
{
ShouldCancelClose = true;
}
StartDate = newStartValue;
}
private void OnDateRangeClose(DateRangePickerCloseEventArgs args)
{
if (ShouldCancelClose)
{
ShouldCancelClose = false;
args.IsCancelled = true;
}
}
}
You can also vote and follow the feature request to revise the DateRangePicker UX. @James, I voted on your behalf.
Regards,
Dimo
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Sankar Kumar,
After an additional review from the development team, we've confirmed that this behavior is not a regression - the DateRangePicker is intended to bahave like so. By design, the calendar popup should close after a valid selection is made. Selecting a new start date that is before the current end date effectively results in a valid date range selection, so the popup closes.
That said, I have marked the item with a "Won't fix" status as it is not a valid bug/regression. In a future product version, we may consider providing an option to keep the popup open in this scenario. This will be tracked as part of the following item: Review DateRangePicker selection UX.
Regards,
Nadezhda Tacheva
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.