jdtcn / BlazorDateRangePicker

A Blazor component for choosing date ranges and dates
MIT License
186 stars 34 forks source link

Mobile Safari: clicking the left/right chevron buttons does not update the Month or Year dropdowns #34

Closed sion-corn closed 4 years ago

sion-corn commented 4 years ago

It works on desktop chrome, but does not work on Mobile Safari. Am I missing something in my implementation?

<DateRangePicker @ref="Picker"
                 SingleDatePicker="true"
                 MinDate="DateTime.Now.AddYears(-130)"
                 MaxDate="DateTime.Now"
                 Opens="SideType.Right"
                 OnRangeSelect="OnRangeSelect"
                 OnMonthChanged="OnMonthChanged"
                 OnSelectionStart="OnSelectionStart"
                 OnOpened="OnOpened"
                 OnClosed="OnClosed"
                 OnCancel="OnCancel">
    <PickerTemplate Context="picker">
        <div class="form-control text-truncate border-right-0" id="@picker.ParentId" @onclick="picker.Toggle">
            <span>
                @if (editUser.Birthday == null)
                {
                    <span>Select dates...</span>
                }
                else
                {
                    <span>@editUser.Birthday.Value.ToString("MM/dd/yyyy")</span>
                }
            </span>
        </div>
        <span class="input-group-text bg-transparent border-left-0 pl-0">
            <i class="material-icons align-text-bottom" role="button" @onclick="picker.Toggle">calendar_today</i>
        </span>
    </PickerTemplate>
</DateRangePicker>

@code{
DateRangePicker Picker;
    private void OnOpened()
    {

    }
    private void OnClosed()
    {

    }
    private void OnCancel(bool byButton)
    {

    }
    private void OnMonthChanged()
    {
        var leftMonth = Picker.LeftCalendar.Month;
        var rightMonth = Picker.RightCalendar.Month;
    }
    private void OnSelectionStart(DateTimeOffset date)
    {
        editUser.Birthday = date.LocalDateTime;
    }
    public void OnRangeSelect(DateRange range)
    {

    }
}
jdtcn commented 4 years ago

Hi, your implementation is fine. It seems there is a bug in blazor (https://github.com/dotnet/aspnetcore/issues/5616).

I've applied the workaround to the demo app (https://blazordaterangepicker.azurewebsites.net/).

Can you please check the demo app in mobile safari and confirm that there is no more issue? If the demo app is fine I'll publish fixed package. And what platform and package version are you using (server-side/wasm/netcore3.1/net5)?

sion-corn commented 4 years ago

@jdtcn Hi Sergey, thanks for taking a look. I checked both the SingleDatePicker and the Custom input markup pages, and it works perfectly. Thanks! Please let me know when I can pull down the package from nuget. Thanks again!

jdtcn commented 4 years ago

I've published fixed packages 2.11.0 & 3.0.0-rc1-02

sion-corn commented 4 years ago

Nice, I updated it and it works - thank you for your quick fix.