jdtcn / BlazorDateRangePicker

A Blazor component for choosing date ranges and dates
MIT License
182 stars 35 forks source link

Fix awaiting change handlers before closing #91

Closed KevinLHansen closed 7 months ago

KevinLHansen commented 9 months ago

This has proven to be an issue for us when we need to do long-running tasks when reacting to change events (specifically, we make an HTTP request when the range changes). Consider the following:

Razor:

<DateRangePicker OnRangeSelect=RangeChanged />

C#:

private async Task RangeChanged(DateRange range)
{
    _Range = range;
    await Save();
}

private async Task Save()
{
   // simulated work
    await Task.Delay(1000);
}

In this example, the selector will only close after 1000ms, whereas it makes more sense UX-wise to close immediately

KevinLHansen commented 8 months ago

@jdtcn Could you take a look at this? :)

jdtcn commented 7 months ago

Hi, thanks for the fix, I will release a new version that will include it soon